# Python O(n) time, O(1) solution with explanation

• If length of two lists are equal, you can iterate a node on each list one by one, and when intersection appears we can detect by checking the `val` of node is the same.

So, what if the length of two lists are different? The answer is easy,

1. First , measure length of both lists
2. Iterate a node on a longer list, until the remaining length becomes equal to the shorter one

It's guaranteed that there is no intersection during iteration of longer list on step2, because if such intersection exists, a shorter list would have longer length than the longer list.
Then, after step2, the problem is come down to the same problem when two lists' length are equal ðŸ¤“

``````    def getIntersectionNode(self, headA, headB):
"""
:rtype: ListNode
"""
return None

# measure length of listA and listB
lenA, lenB = 0, 0
while curA or curB:
if curA:
curA, lenA = curA.next, lenA + 1
if curB:
curB, lenB = curB.next, lenB + 1

# ensure A is always longer
if lenB > lenA: