title: Finding the kth last element of a singly linked list: answer explanation
body: <p>When you need to find the <code>k</code>th last element of a singly linlked list, the usual naive approach is to perform two passes. The first to find the length of the list and the second to iterate until the <code>(length-k)th</code> element. </p>
  
  <p>Whereas the optimized version takes advantage of two pointers:</p>
  
  <ul>
  <li><code>p1</code> refering to the head of the list</li>
  <li><code>p2</code> being <code>k</code>th elements ahead of <code>p1</code></li>
  </ul>
  
  <p>This allows us to return <code>p1</code>'s element when <code>p2</code> reaches the end of the list.
  I don't understand why the second approach is faster than the first when in both cases we have one pointer iterating all over the list and another until the <code>(length-k)th</code> element.</p>
  
  <p>Is it due to cache optimization?</p>
  
  <p>Thanks.</p>