[Python3] CLEAN & CONCISE -> O(n) TC and O(1) SC
If you closely look at every possible soltuion we can find that, same numbers are present in every solution. By this we can sum up that we don\'t need to go dow
If you closely look at every possible soltuion we can find that, same numbers are present in every solution. By this we can sum up that we don\'t need to go down the same path again and again. Instead of maintaining a seperate visited list, we can mark the items in the same list and continue the algorithm.\n```\nclass Solution:\n    def arrayNesting(self, nums: List[int]) -> int:\n        N = len(nums)\n        ans = 1\n        \n        for i in range(N):\n            curLen = 0\n            while nums[i]!= float(inf):\n                temp = i\n                curLen+=1\n                i = nums[i]\n                nums[temp] = float(inf)\n\n            ans = max(ans,curLen)\n        \n        return ans\n            \n\n            \n        \n```
[]