There are soldiers lined up in a row and sorted according to their heights. You want to reverse their order in the row in a minimum number of swaps. Any swap can be done by swapping of two soldiers next to each other.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Swap every i t h person with ( 9 9 − i + 1 ) t h person.
As, 9 9 is an odd number, so 5 0 t h person will be in place. Hence we require 4 9 swaps to sort them in reverse order