Help Needed in Proof

Swapity Swap

Let suppose, initial position of element was A , and the position where it starts to repeat after some number of operation is B.
Now if we solve problem by hand and observe the pattern,the situtation is always like this
image
but why it can’t be like this
image
So , is there any way we can proof that 2nd secenerio will never happen ??

A permutation can always be decomposed into cycles.

1 Like

Thnx … Got it.

could please explain me what do you mean by this, like when I am writing the code for finding after how many repetitions it will start repeating I am unable to understand or proof it that it will not give TLE.