摘要:
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): ... 阅读全文
摘要:
class Solution(object): def largestSumAfterKNegations(self, A, K): """ :type A: List[int] :type K: int :rtype: int """ have_zero = False ne... 阅读全文
摘要:
class Solution(object): def clumsy(self, N): """ :type N: int :rtype: int """ op = {0: '*', 1: '//', 2: '+', 3: '-'} strN = list(map(str, range(N -... 阅读全文
摘要:
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... 阅读全文
摘要:
按位计算就行. 阅读全文
摘要:
bin(7)Out[12]: '0b111'oct(73)Out[13]: '0o111'hex(273)Out[14]: '0x111' 阅读全文
摘要:
class Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ return str(bin(x^y)).count('1') 阅读全文
摘要:
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... 阅读全文