You are viewing a single comment's thread. Return to all comments →
Thanx!! did the same and Voilaa..
boolean hasCycle(Node head) { Node n=head; Node n1=head; boolean present=false; while(n!=null && n.next!=null) { n=n.next.next; n1=n1.next; if(n==n1) { present=true; break; } } return present; }
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 →
Thanx!! did the same and Voilaa..