C++ Solution || Easy DFS
\nclass Solution {\n    void dfs(int node,vector<int>&vis,vector<int>&nums,vector<int>&v){\n    \n        if(vis[node]==1){\n            return;\n        }\n   
```\nclass Solution {\n    void dfs(int node,vector<int>&vis,vector<int>&nums,vector<int>&v){\n    \n        if(vis[node]==1){\n            return;\n        }\n        vis[node]=1;\n        v.push_back(node);\n        if(vis[nums[node]]==0){\n            dfs(nums[node],vis,nums,v);\n        }\n    }\npublic:\n    int arrayNesting(vector<int>& nums) {\n        int i,res=0;\n        vector<int>vis(nums.size(),0);\n        for(i=0;i<nums.size();i++){\n            if(vis[i]==0){\n                vector<int>v;\n                dfs(i,vis,nums,v);\n                int p=v.size();\n                res=max(res,p);\n            }\n        }\n        return res;\n        \n    }\n};\n```
['Depth-First Search', 'C++']