You are viewing a single comment's thread. Return to all comments →
Java Solution
static boolean hasCycle(SinglyLinkedListNode head) { SinglyLinkedListNode fp = head; SinglyLinkedListNode sp = head; while(fp != null && fp.next != null){ fp = fp.next.next; sp = sp.next; if(sp == fp){ 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 →
Java Solution