摘要: import functools class Solution(object): @functools.lru_cache() def mergeTrees(self, t1, t2): if t1 and t2: root = TreeNode(t1.val + t2.val) root.left = self.m... 阅读全文
posted @ 2019-03-23 18:27 周洋 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 按位计算就行. 阅读全文
posted @ 2019-03-23 06:11 周洋 阅读(128) 评论(0) 推荐(0) 编辑
摘要: bin(7)Out[12]: '0b111'oct(73)Out[13]: '0o111'hex(273)Out[14]: '0x111' 阅读全文
posted @ 2019-03-23 04:16 周洋 阅读(446) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ return str(bin(x^y)).count('1') 阅读全文
posted @ 2019-03-23 04:07 周洋 阅读(128) 评论(0) 推荐(0) 编辑
摘要: import functools # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None @functools.l... 阅读全文
posted @ 2019-03-23 02:46 周洋 阅读(245) 评论(0) 推荐(0) 编辑