This commit is contained in:
Gyubin Han
2025-02-19 14:09:55 +09:00
parent e3c6c8b32a
commit dede0dca01
36 changed files with 555 additions and 0 deletions

23
leetcode/160.py Normal file
View 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