MCPcopy Create free account
hub / github.com/apna-college/Alpha / isCycle

Method isCycle

12_LinkedList.java/LL.java:218–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216 }
217
218 public boolean isCycle() {
219 Node slow = head;
220 Node fast = head;
221 while(fast!=null && fast.next!=null) {
222 fast = fast.next.next;
223 slow = slow.next;
224 if(fast == slow) {
225 return true;
226 }
227 }
228 return false;
229 }
230
231 public Node removeCycle() {
232 Node slow = head;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected