c++ | easy to understand | step by step
```\nclass Solution {\npublic:\n    int arrayNesting(vector& a) {\n        size_t maxsize = 0;\n        for (int i = 0; i < a.size(); i++) {\n            size_t
```\nclass Solution {\npublic:\n    int arrayNesting(vector<int>& a) {\n        size_t maxsize = 0;\n        for (int i = 0; i < a.size(); i++) {\n            size_t size = 0;\n            for (int k = i; a[k] >= 0; size++) {\n                int ak = a[k];\n                a[k] = -1;\n                k = ak;\n            }\n            maxsize = max(maxsize, size);\n        }\n\n        return maxsize;\n    }\n};
[]