title: Better way to find matches in two sorted lists than using for loops?
body: <p>I have two sorted lists, both in non-decreasing order. For example, I have one sorted linked list with elements <code>[2,3,4,5,6,7...]</code> and the other one with elements <code>[5,6,7,8,9...]</code>.</p>
  
  <p>I need to find all common elements in both lists. I know I can use a for loop and a nested loop to iterate all matches to find the same two elements. However, is there another way to do this that has running time less than <code>O(n^2)</code>?</p>