格雷编码
程序员文章站
2022-05-29 07:52:55
...
class Solution:
def grayCode(self, n: int) -> List[int]:
res, a = [0], 1
for i in range(n):
for j in range(len(res) - 1, -1, -1):
res.append(a + res[j])
a <<= 1
return res
图解法
上一篇: 第一次打卡
下一篇: 链表练习 两数相加 python