leetcode
This commit is contained in:
23
leetcode/160.py
Normal file
23
leetcode/160.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Definition for singly-linked list.
|
||||
# class ListNode:
|
||||
# def __init__(self, x):
|
||||
# self.val = x
|
||||
# self.next = None
|
||||
|
||||
class Solution:
|
||||
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> Optional[ListNode]:
|
||||
al=set()
|
||||
|
||||
r=None
|
||||
a=headA
|
||||
b=headB
|
||||
while a:
|
||||
al.add(a)
|
||||
a=a.next
|
||||
while b:
|
||||
if b in al:
|
||||
r=b
|
||||
break
|
||||
b=b.next
|
||||
|
||||
return r
|
||||
Reference in New Issue
Block a user