Algobase
Problems
Get Premium
Pricing
Problems
/
160. Intersection of Two Linked Lists
Prev
Next
Visualizer
Problem
Solution
Code
Intersecting
Early Merge
⌥
Visualizer will appear here
Problem
Solution
Code
1
def getIntersectionNode(headA, headB):
2
pA, pB = headA, headB
3
while pA is not pB:
4
pA = pA.next if pA else headB
5
pB = pB.next if pB else headA
6
return pA
Visualizer
Intersecting
Early Merge
⌥
Visualizer will appear here