(Node head, Node fast, Node slow)
| 139 | } |
| 140 | |
| 141 | private static void remove(Node head, Node fast, Node slow) { |
| 142 | if (slow == fast) { |
| 143 | slow = head; |
| 144 | if (slow != fast) { |
| 145 | while (slow.next != fast.next) { |
| 146 | slow = slow.next; |
| 147 | fast = fast.next; |
| 148 | } |
| 149 | // since fast->next is the looping point |
| 150 | fast.next = null; /* remove loop */ |
| 151 | } |
| 152 | // if fast and slow pointer meet at first position. |
| 153 | else { |
| 154 | while (fast.next != slow) { |
| 155 | fast = fast.next; |
| 156 | } |
| 157 | fast.next = null; |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // time complexity : O(N) |
no outgoing calls
no test coverage detected