python soln

  • 0
    class Solution(object):
        def detectCycle(self, head):
            :type head: ListNode
            :rtype: ListNode
            slow = head
            fast = head
            while fast and
                slow =
                fast =
                if fast == slow:
                    temp = head
                    while temp != slow:
                        temp =
                        slow =
                    return temp
            return None

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.