Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Problem 160 - Intersection of Two Linked Lists

Required algorithm performance:
T(n) = O(n), S(n) = O(1).
Algorithm details:

  1. Find the sizes of two linked lists. If their tails are different, return null.
  2. Calculate the deviation(D) of two linked lists and let the longer linked list's pointer point to the next Dth node.
  3. Iterate two linked lists simultaneously until find the common node.