222. Gray Code
MediumBitsRecursion
Print the standard n-bit reflected Gray code sequence as decimal numbers (consecutive values differ in one bit, starting at 0).
Input format
A single integer n.
Output format
2ⁿ numbers.
Example 1
Input
2
Output
0 1 3 2
Example 2
Input
1
Output
0 1
Constraints
1 ≤ n ≤ 12
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…