C Simple Solution using Flags, TC: O(n), SC: O(1)
My solution uses flags to prevent repetition of tested values.\n\nint arrayNesting(int* nums, int numsSize){\n    int max = 0;\n    int counter = 0;\n    for(in
My solution uses flags to prevent repetition of tested values.\n```\nint arrayNesting(int* nums, int numsSize){\n    int max = 0;\n    int counter = 0;\n    for(int i = 0; i < numsSize; i++)\n    {\n        if(nums[i] != -1)\n        {\n            int j = nums[i]; \n            counter = 0;\n            while(j != i)\n            {\n                counter++;\n                int temp = nums[j];\n                nums[j] = -1;\n                j = temp;\n            }\n            counter++;\n            if(counter > max)\n                max = counter;\n        }\n            \n    }\n    return max;\n}\n```
['Array', 'C']