MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / getIntersectionNode

Method getIntersectionNode

Array/IntersectionOfTwoLinkedLists.py:91–108  ·  view source on GitHub ↗

:type head1, head1: ListNode :rtype: ListNode

(self, headA, headB)

Source from the content-addressed store, hash-verified

89
90class Solution(object):
91 def getIntersectionNode(self, headA, headB):
92 """
93 :type head1, head1: ListNode
94 :rtype: ListNode
95 """
96
97 a = headA
98 b = headB
99
100 if not a or not b:
101 return None
102
103 while a != b:
104
105 a = headB if a is None else a.next
106 b = headA if b is None else b.next
107
108 return a

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected