You are viewing a single comment's thread. Return to all comments →
The old "tortoise and the hare" problem in python.
def has_cycle(head): cycle=False slow=head fast=head while head and head.next: if slow==fast: cycle=True break slow=slow.next fast=fast.next.next return cycle
Seems like cookies are disabled on this browser, please enable them to open this website
Cycle Detection
You are viewing a single comment's thread. Return to all comments →
The old "tortoise and the hare" problem in python.