LeetCode刷题(47)--Gray Code

来源:互联网 发布:电脑运行命令网络连接 编辑:程序博客网 时间:2024/06/16 03:18

格雷码,倒序加2**i

class Solution(object):    def grayCode(self, n):        """        :type n: int        :rtype: List[int]        """        res = [0]        for i in range(n):            res += [x + pow(2,i) for x in reversed(res)]        return res
原创粉丝点击