Has to say this is actually wrong, and it only passed OJ by luck; One key point of the algorithm is the starting point has to be guaranteed out of loop, and neither on a independent closed loop. (Think about the graph, it is not guarantee that all the nodes will together form a giant rho graph, instead, there could be several independent closed loops existing, like 1->1, or 2->3->4->2, if you happened to pick the starting point in any of these closed loops, you are doomed). Thats why the problem gave array of length n+1 (index 0 to n), and make the value range 1 to n, that makes 0 the special point, whose value must point to the real rho graph, not any closed loop. And a correct solution must select 0 as the starting point.