1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ if headA is None or headB is None: return None pA = headA pB = headB while pA != pB: if pA is None: pA = headB else: pA = pA.next if pB is None: pB = headA else: pB = pB.next return pA
|