Circular Permutation in Binary Representation LeetCode solution in Python

1
class Solution:
2
def circularPermutation(self, n: int, start: int) -> List[int]:
3
gray_code = [x ^ (x >> 1) for x in range(2**n)]
4
start_i = gray_code.index(start)
5
return gray_code[start_i:] + gray_code[:start_i]

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0