上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 33 下一页
摘要: # 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): ... 阅读全文
posted @ 2019-04-02 18:14 周洋 阅读(156) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def largestSumAfterKNegations(self, A, K): """ :type A: List[int] :type K: int :rtype: int """ have_zero = False ne... 阅读全文
posted @ 2019-03-30 07:49 周洋 阅读(164) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def clumsy(self, N): """ :type N: int :rtype: int """ op = {0: '*', 1: '//', 2: '+', 3: '-'} strN = list(map(str, range(N -... 阅读全文
posted @ 2019-03-30 07:00 周洋 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: class Solution(object): def strStr(self, haystack, needle): """ :type haystack: str :type needle: str :rtype: int """ return haystack.find(needle) ... 阅读全文
posted @ 2019-03-22 06:20 周洋 阅读(154) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def repeatedSubstringPattern(self, s): return True if re.match(r'(\w+)\1+$', s) else False 阅读全文
posted @ 2019-03-22 01:29 周洋 阅读(168) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 33 下一页