Skip to main content
1 of 3

In order to overlap any previous numbers you have to swap with it atleast once. Now for every number at pos p you have atleast n-p-1 numbers to be swapped with.

So solution will be sum 1 to n-1 i.e n*(n-1)/2

for 5 4 3 2 1

5 needs to be swapped with 4 numbers 4 needs to be swapped with 3 numbers 3 needs to be swapped with 2 numbers 2 needs to be swapped with 1 number.

Thus 1+2+3+4 = 10