Straight Forward C++ DFS Solution
\nclass Solution {\npublic:\n    int longest = 1;\n    int arrayNesting(vector<int>& nums) {\n        vector<bool> v(nums.size());\n        for(int i = 0; i < n
```\nclass Solution {\npublic:\n    int longest = 1;\n    int arrayNesting(vector<int>& nums) {\n        vector<bool> v(nums.size());\n        for(int i = 0; i < nums.size(); i++){\n            longest = max(longest, dfs(v, nums, i));\n            v = {false};\n        }\n        return longest;\n    }\n    int dfs(vector<bool>& v, vector<int>& nums, int i){\n        if(v[i])\n            return 0;\n        v[i] = true;\n        return 1 + dfs(v, nums, nums[i]);\n    }\n};\n```
['Depth-First Search', 'C']