Share python with explanation

  • 0
    class Solution(object):
    def detectCycle(self, head):
        :type head: ListNode
        :rtype: ListNode
        if not head:return None
        while p and q:
            else:return None
            if and
            else:return None
            if p==q:break
        while p!=r:
        return r

    the main idea is come from this blog

Log in to reply

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