You are viewing a single comment's thread. Return to all comments →
My solution in JAVA. Floyd's cycle detection algorithm
static boolean hasCycle(SinglyLinkedListNode head) { SinglyLinkedListNode slowNode = head, fastNode = head; while(fastNode != null && fastNode.next != null ){ System.out.println("tilin"); slowNode = slowNode.next; fastNode = fastNode.next.next; if(slowNode == fastNode){ 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 →
My solution in JAVA. Floyd's cycle detection algorithm