Leetcode 89. Gray Code
Generate any sequence of 2^n distinct integers in [0, 2^n-1] starting at 0 such that consecutive numbers (and the first and last) differ by exactly one bit—equivalently, produce a Hamiltonian cycle/traversal of the n-dimensional hypercube. Constraint: 1 ≤ n ≤ 16 (output length 2^n).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.