You are viewing a single comment's thread. Return to all comments →
boolean hasCycle(Node head) { if(head == null){ return false; } Node fast = head; while(head.next != null && fast != null){ head = head.next; fast = fast.next.next; if(head == fast){ return true; } } 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 →