Example 1:
Input: [3, 7, 2, 6, 1, 9]
Output: [3, 1, 2, 6, 7, 9]
Explanation:
In the input vector, the next to largest value is 7 and the next to smallest value is 2. Swapping these two values will result in the output vector.
Example 2:
Input: [5, 9, 12, 4, 8, 1, 6]
Output: [5, 1, 12, 4, 8, 9, 6]
Explanation:
In the input vector, the next to largest value is 9 and the next to smallest value is 4. Swapping these two values will result in the output vector.
Example 3:
Input: [1, 2, 3, 4, 5, 6, 7, 8]
Output: [1, 7, 3, 4, 5, 6, 2, 8]
Explanation:
In the input vector, the next to largest value is 7 and the next to smallest value is 2. Swapping these two values will result in the output vector.
Example 4:
Input: [10, 15, 20, 25, 30, 35, 40]
Output: [10, 35, 20, 25, 30, 15, 40]
Explanation:
In the input vector, the next to largest value is 35 and the next to smallest value is 15. Swapping these two values will result in the output vector.