You are viewing a single comment's thread. Return to all comments →
I did the same in Python. I don't like the hare and tortoise solution.
def has_cycle(head): curr = head seen = set() while curr: if curr in seen: return True seen.add(curr) curr = curr.next return False
Seems like cookies are disabled on this browser, please enable them to open this website
Linked Lists: Detect a Cycle
You are viewing a single comment's thread. Return to all comments →
I did the same in Python. I don't like the hare and tortoise solution.