For example, starting at index 1, nums[1] is 1, move 1 step forward to index 2. Then nums[2] is 1, move back 1 step to index 1. The loop contains indices 1 and 2. Is this a valid loop?
I cannot understand why test case [2, 1, 1, 2, 2] gives false?

@czhangaegean This was my question exactly. See the last line in the problem statement. Loop can be either "forward" or "backward", ie. you cannot change direction. So no, 1>2, 2>1 is not a valid loop.

It is a good question. At least, many people will interpret the loop the same way as what @czhangaegean thinks about.
The forward loop or backward one stated at the end of the problem is not a common way to interpret loop.

@satyaaditya Then what about the case [1,2]? If we start from index 1 and search forwards: because nums[1]=2 so it's 1>1. So I think it's also a valid answer, isn't it?

@qintxx A loop starts and ends at a particular index with more than 1 element along the loop.

@princessmaja said in I cannot understand why test case [2, 1, 1, 2, 2] gives false?:
@czhangaegean This was my question exactly. See the last line in the problem statement. Loop can be either "forward" or "backward", ie. you cannot change direction. So no, 1>2, 2>1 is not a valid loop.
@princessmaja : Can you please explain what is the meaning of forward and backward loop here ? Considering the given example why this [0>3>1>2>1] is not considered to be a loop ?

I ran in the same question, yet I would say the problem is well worded... and cunning. :)
The forward and backward loops could have been defined explicitly yet the reader can figure out what they mean... once he/she pays attention to them! In the heat of the fight I certainly did not.
In case of the [1,2] observe that there is no valid loop. 2 maps to itself and 1 maps to 2.
In case of [1,1] we have a valid loop a both "edges" go forward and close a loop of 2 vertices.
Finally, see that [1,1] does not contain a valid loop as one of the edges goes forward and the other one goes backward.Hope that helps. Note that If you have solved the problem for finding any loop of at least two vertices, chances are your code can be quickly modified to the right one.