Beautiful Arrangement II
MediumLeetCodeConstructive Algorithms
Approach hintTry it first, then revealHide
Arrange 1..k+1 in the zig-zag order 1, k+1, 2, k, ..., which produces the differences k, k-1, ..., 1. Appending k+2..n in increasing order introduces no new difference.