You have soldiers standing in a row, each with a specific height. You need to move the tallest soldier to the front and the shortest soldier to the back. Each swap with an adjacent soldier takes one second.
Your task: calculate the minimum time needed. This tests your understanding of finding minimum and maximum elements, plus counting swaps. The STL provides functions to find positions directly.
Before reading on, think: how many swaps does it take to move an element from position to position ? What if you need to move two elements in opposite directions?