Created
November 4, 2019 16:42
-
-
Save imedadel/477ff3a413b083d69e4a214622db9d6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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