- class Solution:
- def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
- if headA is None or headB is None:
- return None
- pA=headA
- pB=headB
- while(pA!=pB):
- pA=headB if pA is None else pA.next
- pB=headA if pB is None else pB.next
- return pA
- 作者:LeetCode-Solution
- 链接:https://leetcode-cn.com/problems/intersection-of-two-linked-lists/solution/xiang-jiao-lian-biao-by-leetcode-solutio-a8jn/
- 来源:力扣(LeetCode)
- 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
if headA is None or headB is None:
return None
pA=headA
pB=headB
while(pA!=pB):
pA=headB if pA is None else pA.next
pB=headA if pB is None else pB.next
return pA
作者:LeetCode-Solution
链接:https://leetcode-cn.com/problems/intersection-of-two-linked-lists/solution/xiang-jiao-lian-biao-by-leetcode-solutio-a8jn/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。