Wave Arrangement — Solution & Editorial
Sort ascending, then swap each adjacent pair (positions 1↔2, 3↔4, ...) — sorting first makes it lexicographically smallest among waves.
Complexity: O(N)
Sort ascending, then swap each adjacent pair (positions 1↔2, 3↔4, ...) — sorting first makes it lexicographically smallest among waves.
Complexity: O(N)