Search
⌘K

Leetcode 667. Beautiful Arrangement II

Construct a permutation of 1..n such that the multiset of absolute differences between consecutive elements contains exactly k distinct values. The typical challenge is to design a sequence (commonly by alternating low/high to produce k distinct gap sizes, then filling the remainder sequentially) that yields precisely k distinct adjacent differences.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.