89. 格雷编码
https://leetcode-cn.com/problems/gray-code/
解法一:
思路很简单,用异或G(i) = i^ (i/2)
class Solution:
def grayCode(self, n: int) -> List[int]:
res = []
for i in range(2**n):
res.append(i ^ i//2)
return res
最后更新于