Easy Java Solution 100% faster (1 ms)
\nclass Solution {\n    public int arrayNesting(int[] nums) {\n      \n        int count,max=0;\n        for(int i=0;i<nums.length;i++){\n          count=0;\n  
```\nclass Solution {\n    public int arrayNesting(int[] nums) {\n      \n        int count,max=0;\n        for(int i=0;i<nums.length;i++){\n          count=0;\n            int index=i;\n            while(nums[index]!=-999){     \n                int temp=nums[index];\n                nums[index]=-999;\n                index=temp;\n                count++;\n            }\n          max=Math.max(count,max);\n      }\n        return max;\n    }\n}\n```
['Java']