Simple python code


  • 1
    C
    class Solution(object):
        def grayCode(self, n):
            """
            :type n: int
            :rtype: List[int]
            """
            if n > 0:
                return self.grayCode(n - 1) + \
                [x + 2**(n-1) for x in self.grayCode(n - 1)[::-1]]
            else:
                return [0]

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.