Python Simple
Accepted and Easy to understand solution\n\nclass Solution:\n    def arrayNesting(self, nums: \'List[int]\') -> \'int\':\n        res = 0\n        for i in rang
Accepted and Easy to understand solution\n```\nclass Solution:\n    def arrayNesting(self, nums: \'List[int]\') -> \'int\':\n        res = 0\n        for i in range(len(nums)):\n            cache = set()\n            j = i\n            while nums[j] < len(nums) and len(cache) <= len(nums) and j not in cache and j >=0:\n                cache.add(j)\n                tmp = nums[j]\n                nums[j] = -1\n                j = tmp\n            res = max(len(cache), res)\n        return res\n```
[]