For each position i that has non-zero value:

- Determine the direction
- Check for loop (see if there is a valid path with length more than array size)
- If no loop, start from i again and change value along path to 0.

```
bool circularArrayLoop(vector<int>& nums) {
//next index
#define n(i) ((nums[i]+i)%nums.size())
int count, check, mark, mode;
for( int i = 0; i < nums.size(); i ++ ){
if( nums[i] != 0 ){
//check the direction
mode = nums[i] > 0? 1:-1;
count = 0; check = i; mark = i;
//check for loow
while( count++ <= nums.size() + 1&& mode*nums[n(check)] > 0 && n(check) != check )
check = n(check);
//a path longer than array size means there is a loop
if( count > nums.size() + 1 ) return true;
//mark all nodes in path as 0
while( nums[mark] > 0 ){ mark = n(mark); nums[mark] = 0; }
}
}
return false;
}
```