leetcode-160周赛-5239-循环码排列

题目描述:

 

 参考格雷编码:

class Solution:
    def circularPermutation(self, n: int, start: int) -> List[int]:
        res = [] 
        for i in range(2 ** n): 
            res.append((i >> 1) ^ i) 
        start = res.index(start)
        return res[start:] + res[:start]

 

posted @ 2019-10-28 10:08  oldby  阅读(156)  评论(0编辑  收藏  举报