Leetcode Problem 1238. Circular Permutation in Binary Representation
1238. Circular Permutation in Binary Representation
Leetcode Solutions
Generating Circular Permutation using Gray Code
Initialize an empty list result.
Loop through i from 0 to 2^n - 1:
a. Calculate the Gray code for i using the formula i ^ (i >> 1).
b. XOR the result with start to align the sequence with the given start value.
c. Append the result to the result list.