<filename>codes_/0142_Linked_List_Cycle_II.py
# %% [142. Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii/)
class Solution:
    def detectCycle(self, head: ListNode) -> ListNode:
        st = set()
        while head:
            i = id(head)
            if i in st:
                return head
            st.add(i)
            head = head.next
        return None

<filename>codes_/0142_Linked_List_Cycle_II.py
# %% [142. Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii/)
class Solution:
    def detectCycle(self, head: ListNode) -> ListNode:
        st = set()
        while head:
            i = id(head)
            if i in st:
                return head
            st.add(i)
            head = head.next
        return None

# %% [142. Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii/)