Python solution
python\nclass Solution:\n    def arrayNesting(self, nums: List[int]) -> int:\n        result = 0\n        visited = set()\n        for i in range(len(nums)):\n 
```python\nclass Solution:\n    def arrayNesting(self, nums: List[int]) -> int:\n        result = 0\n        visited = set()\n        for i in range(len(nums)):\n            length = 0\n            while not i in visited:\n                length += 1\n                visited.add(i)\n                i = nums[i]\n            result = max(result, length)\n        return result\n```
[]