This problem taught you to use STL search algorithms. Instead of writing loops to find minimum and maximum, you call min_element() and max_element(). These return positions, not just values.
I showed you how to think about swaps mathematically. You calculate how far each element travels and check if paths cross. This converts operations into arithmetic. You learned to watch for interaction between independent operations.
Moving the tallest and shortest soldiers are separate tasks, but they affect each other if they cross. Check for such dependencies.