Skip to content

Instantly share code, notes, and snippets.

@imedadel
Created November 4, 2019 16:42
Show Gist options
  • Save imedadel/477ff3a413b083d69e4a214622db9d6a to your computer and use it in GitHub Desktop.
Save imedadel/477ff3a413b083d69e4a214622db9d6a to your computer and use it in GitHub Desktop.
def has_cycle(head):
if head is None or head.next is None or head.next.next is None:
return False
count = 0
while head.next:
head = head.next
count += 1
if count > 100:
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment