Skip to content

Latest commit

 

History

History
21 lines (19 loc) · 476 Bytes

160.md

File metadata and controls

21 lines (19 loc) · 476 Bytes
  • 160ms
  • 87%
# 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) -> ListNode:
        hash = set()
        while headA:
            hash.add(headA)
            headA = headA.next
        while headB:
            if headB in hash: return headB
            headB = headB.next
        return None