class Solution:
    def grayCode(self, n):
        res = [0]  # [1]
        add = 1  # [2]
        for _ in range(n):
            for i in range(add):
                res.append(res[add - 1 - i] | add)  # [3]
            add <<= 1  # [4]
        return res
de1d1a52aaa8fc0353aaae065aa4de7a0010079a
<mask token>

class Solution:
    <mask token>

class Solution:

    def grayCode(self, n):
        res = [0]
        add = 1
        for _ in range(n):
            for i in range(add):
                res.append(res[add - 1 - i] | add)
            add <<= 1
        return res

class Solution:
    def grayCode(self, n):
        res = [0]  # [1]
        add = 1  # [2]
        for _ in range(n):
            for i in range(add):
                res.append(res[add - 1 - i] | add)  # [3]
            add <<= 1  # [4]
        return res