Beautiful Permutation — Solution & Editorial
Evens-then-odds only ever puts a gap of 1 at the junction of the two blocks — and there the values differ by more than 1 for N ≥ 4. N = 2, 3 are impossible; N = 1 is the trivial 1.
Complexity: O(N)
Evens-then-odds only ever puts a gap of 1 at the junction of the two blocks — and there the values differ by more than 1 for N ≥ 4. N = 2, 3 are impossible; N = 1 is the trivial 1.
Complexity: O(N)