Problems > Wave Arrangement > Editorial

Wave Arrangement — Solution & Editorial

Back to the Problem

Sort ascending, then swap each adjacent pair (positions 1↔2, 3↔4, ...) — sorting first makes it lexicographically smallest among waves.

Complexity: O(N)