Although it's double circulation, actually, each number is traversed just once. So it's still O(n) runtime

```
class Solution(object):
def arrayNesting(self, nums):
l,m=len(nums),0
for i in range(l):
if nums[i]==-1:continue
if m>=l-m:return m
j,c=nums[i],0
while nums[j]!=-1:
c+=1
t=nums[j]
nums[j],j=-1,t
if c>m:m=c
return m
```