Python Solution


  • 0
    K

    Python O(n) Solution

    class Solution(object):
        def hasCycle(self, head):
            fast = slow = head
            while fast and fast.next:
                fast = fast.next.next
                slow = slow.next
                if slow == fast:
                    return True
            return False
    

Log in to reply
 

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