无聊的题目,考Gray Code的概念。。。
class Solution(object):
def grayCode(self, n):
"""
:type n: int
:rtype: List[int]
"""
ans=[]
for i in range(1<<n):
ans.append((i>>1)^i)
return ans
无聊的题目,考Gray Code的概念。。。
class Solution(object):
def grayCode(self, n):
"""
:type n: int
:rtype: List[int]
"""
ans=[]
for i in range(1<<n):
ans.append((i>>1)^i)
return ans