Solution C++
```\nclass Solution {\npublic:\n    int arrayNesting(vector& nums) {\n        int ans = 0,n = nums.size(),k,temp;\n        for(int i = 0;i<n;i++){\n            
```\nclass Solution {\npublic:\n    int arrayNesting(vector<int>& nums) {\n        int ans = 0,n = nums.size(),k,temp;\n        for(int i = 0;i<n;i++){\n            k = i;\n            temp = 0;\n            while(nums[k] != -1){\n                temp++;\n                int y = k;\n                k = nums[k];\n                nums[y] = -1;\n            }\n            ans = max(ans,temp);\n        }\n        return max(ans,temp);\n    }\n};
['C']