The loop doesn't have to begin at 0. In the case of [3,1,2], there is this loop:
@mpmg But the case
[-2, 1, -1, -2, -2] where loop in 1->2->1 return false
@mpmg not sure if i follow this
if the first value at index 0 is 3, then the new index will be 0+3 = 3 which will come back to 0. hence it will be 0->0->0 hence circular loop that has only one element. can you please explain why this is the valid loop?
@vadimsf The question is if there exists any loop, not whether starting from the first element puts you on a loop.
The 0->0 loop doesn't matter, but the 1->2->1 loop is valid.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.