GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/089_Gray_Code.py at master · Weihouye/leetcode Expand file tree/ Copy path089_Gray_Code.pyMore file actions 25 lines (21 loc) · 585 Bytes / Copy path089_Gray_Code.pyFile metadata and controls25 lines (21 loc) · 585 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 class Solution(object): def grayCode(self, n): """ :type n: int :rtype: List[int] """ # https://leetcode.com/discuss/86617/6-line-java-solution-very-concise res = [0] for i in range(n): for j in reversed(range(len(res))): res.append(res[j] + (1 << i)) return res # def count_one(self, num): # count = 0 # while num: # num &= (num - 1) # count += 1 # return count if __name__ == "__main__": s = Solution() print s.grayCode(2) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |