Here's your approach:
Read the array of heights.
Find the position of the maximum element using
Calculate swaps for max: The solution combines STL search functions with arithmetic. You find positions with library calls, then use math to count swaps. No loops needed for the actual movement. Each step should be clear and testable. Before coding, trace through with a small example to verify the logic. Think about edge cases: empty input, single element, maximum values. Make sure your algorithm handles them correctly.