Search
⌘K

Leetcode 526. Beautiful Arrangement

Count the permutations of 1..n such that for every position i, either perm[i] is divisible by i or i is divisible by perm[i]. With n ≤ 15 this is typically solved by exponential search with pruning (backtracking) or DP over subsets using bitmasks.


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.