3
int next(vector<int> &nums, int i) {5
return (n + nums[i] + i) % n;8
bool circularArrayLoop(vector<int> &nums) {10
// we can use slow and fast pointer to check whether there is loop or not11
for (int &num : nums) num %= n;12
for (int i = 0; i < n; i++) {13
int slow = i, fast = i;14
while (nums[slow] * nums[next(nums, fast)] > 0 &&15
nums[slow] * nums[next(nums, next(nums, fast))] > 0) {16
slow = next(nums, slow);17
fast = next(nums, next(nums, fast));19
if (slow == next(nums, slow)) // single length24
/// DONOT TRAVERSE WHERE THERE IS NO PATH TO GET LOOP.27
while (nums[j] * val > 0) {28
int nexx = next(nums, j);