Here's your approach:
Read and the heights array.
Find the position of the maximum height (leftmost if there are ties).
Find the position of the minimum height (rightmost if there are ties).
Calculate swaps for max: The tricky part is the overlap. When the tallest starts right of the shortest, they pass each other once during movement. That shared swap counts for both. 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.