MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / isCycleExists

Method isCycleExists

Java/linked-list-cycle-ii.java:34–49  ·  view source on GitHub ↗
(ListNode head)

Source from the content-addressed store, hash-verified

32 }
33
34 public ListNode isCycleExists(ListNode head){
35 ListNode currentHead = head;
36
37 ListNode slowPtr = head;
38 ListNode fastPtr = head;
39
40 while (fastPtr != null && fastPtr.next != null) {
41 slowPtr = slowPtr.next;
42 fastPtr = fastPtr.next.next;
43
44 if (slowPtr == fastPtr)
45 return slowPtr;
46 }
47
48 return null;
49 }
50
51}

Callers 1

detectCycleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected