Confusion about question/ testcase
Hi so i understand the ask of the question. But in the event of a test case of [0,2,1] or [0,1,2] or even [0,anything,anything]\nHow is it that the answer can b
Hi so i understand the ask of the question. But in the event of a test case of [0,2,1] or [0,1,2] or even [0,anything,anything]\nHow is it that the answer can be more then 1 if we are starting at index 0 and num[0] points to 0 it would just be a cycle of going to the [0] index in the array, the question states that We stop adding right before a duplicate element occurs in s[k].\n\nSo i am confused on how in the test case 0,2,1 how the answer could be more then 1.\nIm sure its something small i am missing but just stuck after getting 3/4s test cases right.\n\nmy basic logic is have an arraylist that we would add the values in.\n```\nwhile(!isDup && counter < nums.length){\n            if(arr.contains(nums[current])){\n               isDup=true;\n                break;  // meaning duplicate is found\n            }\n                \n            else\n                arr.add(nums[current]);\n                current = nums[current];\n                counter++;\n                \n        }\n        \n        return arr.size();\n```\n\nIm sure the code isnt effiencient but this is more to understand the question and test cases fully
[]