You are viewing a single comment's thread. Return to all comments →
def has_cycle(head): if not head or not head.next: return 0 p = q = head while(True): p = p.next q = q.next q = q.next if (q) else None if(p and q and p != q): continue else: break if( p == q ): return 1 else: return 0
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 →
Python code for Cycle detection
**Works Totally well for all the test cases **
Upvote it if you found it pretty helpful & Do Comment below for any suggestions⛳