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