Simple Python solution!

  • 5
    class Solution(object):
        def hasCycle(self, head):
            :type head: ListNode
            :rtype: bool
            slow = head
            fast = head
            while fast is not None and is not None:
                fast =
                slow =
                if fast == slow:
                    return True
            return False

  • 0

    nice solution!

Log in to reply

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