
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Each element of the array should be obtained by “merging” <code>x</code> and <code>v</code> where <code>v = 0, 1, 2, …(n - 1)</code>.
To merge <code>x</code> with another number <code>v</code>, keep the set bits of <code>x</code> untouched, for all the other bits, fill the set bits of <code>v</code> from right to left in order one by one.
So the final answer is the “merge” of <code>x</code> and <code>n - 1</code>.