Brute force | C++
Please upvote if it helped you :)\n\nclass Solution {\npublic:\n    int arrayNesting(vector<int>& nums) {\n        int s=nums.size();\n        vector<bool>v(s,f
Please upvote if it helped you :)\n```\nclass Solution {\npublic:\n    int arrayNesting(vector<int>& nums) {\n        int s=nums.size();\n        vector<bool>v(s,false);\n        int res=0;\n        for(auto x:nums){\n            int cnt=0;\n            while(v[x]==false){\n                v[x]=true;\n                cnt++;\n                x=nums[x];\n            }   \n            res=max(cnt,res);\n        }\n        return res;      \n    }\n};\n```
[]