美文网首页
89. Gray Code

89. Gray Code

作者: 阿团相信梦想都能实现 | 来源:发表于2016-12-13 06:58 被阅读0次
    class Solution(object):
        def grayCode(self, n):
            """
            :type n: int
            :rtype: List[int]
            """
            if n==0: return [0]
            last_level=self.grayCode(n-1)
            return last_level+map(lambda x:x+(1<<(n-1)),last_level[::-1])
    

    相关文章

      网友评论

          本文标题:89. Gray Code

          本文链接:https://www.haomeiwen.com/subject/pxpvmttx.html