You are viewing a single comment's thread. Return to all comments →
Thanks for your solution. How about this solution. I tried to make it more general. What if we don't know about 100?
visited = [] def has_cycle(head): if head: visited.append(head.data) if head.next: if head.next.data in visited: return True else: has_cycle(head.next) else: return False else: return False
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 →
Thanks for your solution. How about this solution. I tried to make it more general. What if we don't know about 100?