2
public boolean circularArrayLoop(int[] nums) {3
for (int i = 0; i < nums.length; i++) {4
boolean isForward = nums[i] > 0;8
slow = findNextIndex(nums, isForward, slow);9
fast = findNextIndex(nums, isForward, fast);11
fast = findNextIndex(nums, isForward, fast);13
} while (slow != -1 && fast != -1 && slow != fast);14
if (slow != -1 && slow == fast) {21
private int findNextIndex(int[] arr, boolean isForward, int currentIndex) {22
boolean direction = arr[currentIndex] >= 0;23
if (isForward != direction) {26
int nextIndex = (currentIndex + arr[currentIndex]) % arr.length;28
nextIndex += arr.length;30
if (nextIndex == currentIndex) {