You're observing soldiers standing in a row, each with a different height. The general wants the tallest soldier at the front and the shortest at the back. You can swap adjacent soldiers, and each swap takes second.
Your task: find the minimum time to arrange the soldiers correctly. This tests your ability to track both values and their positions using pairs. Before reading further, think: if the tallest soldier is at position and the shortest at position in a line of soldiers, how many swaps do you need?