You are viewing a single comment's thread. Return to all comments →
def has_cycle(head): l=[] while head is not None: if head.data in l: return 1 l.append(head.data) head = head.next return 0
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 →
def has_cycle(head): l=[] while head is not None: if head.data in l: return 1 l.append(head.data) head = head.next return 0