[JAVA] Self Documented Code(Descriptive variable names), Easy to understand
Not the best solution since this can be done using O(1) space but this solution is definitely easy and intuitive to understand.\n\n\nclass Solution {\n    publi
Not the best solution since this can be done using O(1) space but this solution is definitely easy and intuitive to understand.\n\n```\nclass Solution {\n    public int arrayNesting(int[] nums) {\n        HashSet<Integer> visitedNumbers = new HashSet<Integer>();\n        int count;\n        int maxCount = 0;\n        int currentNumber;\n        \n        for(int i=0; i<nums.length; i++){\n            currentNumber = nums[i];\n            count = 0;\n            while(true){\n                if(visitedNumbers.contains(currentNumber)) \n                    break;\n                else {\n                    visitedNumbers.add(currentNumber);\n                    currentNumber = nums[currentNumber];\n                    count++;\n                }\n            }\n            maxCount = Math.max(count, maxCount);\n        }\n        return maxCount;\n    }\n}\n```
[]