Skip to main content
added 4 characters in body
Source Link
Fabich
  • 7.2k
  • 2
  • 35
  • 59

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_{i=1}^n i = \frac{n*(n-1)}{2}$$$$\sum_{i=1}^{n-1} i = \frac{n*(n-1)}{2}$$

Example 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

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_{i=1}^n i = \frac{n*(n-1)}{2}$$

Example 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

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_{i=1}^{n-1} i = \frac{n*(n-1)}{2}$$

Example 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

spoiler + math formulas
Source Link
Fabich
  • 7.2k
  • 2
  • 35
  • 59

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

$$\sum_{i=1}^n i = \frac{n*(n-1)}{2}$$

Example for 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

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

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

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_{i=1}^n i = \frac{n*(n-1)}{2}$$

Example 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

Source Link

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