Skip to content

Instantly share code, notes, and snippets.

@thekhairul
Created May 21, 2022 04:42
Show Gist options
  • Save thekhairul/be1fd6f90de39099a089550e489b36e3 to your computer and use it in GitHub Desktop.
Save thekhairul/be1fd6f90de39099a089550e489b36e3 to your computer and use it in GitHub Desktop.
Leetcode 141: Linked List Cycle - python
def hasCycle(head):
fast, slow = head, head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment