Sample Output not clear

Hi,
Can u explain how they have calculated output?

Hello @vatsal50 you can check this:
Input: [3,2,4,1]
Pick highest element so far. Do swaps to bring it to last position.
In the input ,4 is the highest. So subarray from 3 to 4 is reversed.
Swap 1: 4 2 3 1
The whole array is then reversed such that 4 reaches its desired position.
Swap 2: 1 3 2 4
Now the unsorted window is from index 0 to 2.Highest element in this window is 3.So subarray 1 3 is reversed
Swap 3: 3 1 2 4
Swap the whole window such that 3 reaches its desired position.
Swap 4: 2 1 3 4
Now the unsorted window is from index 0 to 1. Highest element in this window is 2.
Swap 5:1 2 3 4

Is the output shown incorrect?

@vatsal50 is it still incorrect?

No, I am asking about the output shown in question

@vatsal50 no i think it must be correct.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.