c++ easy and simple code without extra space faster than 97%
class Solution {\npublic:\n    int arrayNesting(vector& nums) {\n        int res=INT_MIN;\n        for(int i=0;i<nums.size();i++)\n        {\n            if(num
class Solution {\npublic:\n    int arrayNesting(vector<int>& nums) {\n        int res=INT_MIN;\n        for(int i=0;i<nums.size();i++)\n        {\n            if(nums[i]!=INT_MAX)\n            {\n                int start=nums[i];\n                int count=0;\n                while(nums[start]!=INT_MAX)\n                {\n                    int temp=start;\n                    start=nums[start];\n                    count++;\n                    nums[temp]=INT_MAX;\n                }res=max(res,count);\n            }\n        }return res;\n    }\n};\ndo upvote if you find it useful..
['C', 'C++']