02 2020 档案
leetcode1362
摘要:1 class Solution: 2 def closestDivisors(self, num: int) -> List[int]: 3 d = float("inf") 4 res = [] 5 for i in range(1, int((num + 1) ** 0.5 + 1)): 6 阅读全文
posted @ 2020-02-23 17:34 Sempron2800+ 阅读(203) 评论(0) 推荐(0)
leetcode1361
摘要:1 class TreeNode: 2 def __init__(self, x): 3 self.val = x 4 self.left = None 5 self.right = None 6 7 class Solution: 8 def __init__(self): 9 self.node 阅读全文
posted @ 2020-02-23 16:32 Sempron2800+ 阅读(172) 评论(0) 推荐(0)
leetcode1360
摘要:1 import datetime 2 class Solution: 3 def daysBetweenDates(self, date1: str, date2: str) -> int: 4 year1,month1,day1 = date1.split('-') 5 d1 = datetim 阅读全文
posted @ 2020-02-23 13:49 Sempron2800+ 阅读(126) 评论(0) 推荐(0)
leetcode1358
摘要:1 class Solution: 2 def numberOfSubstrings(self, s: str) -> int: 3 n = len(s) 4 prelist = [] 5 for i in range(n): 6 a_index = s.find('a',i) 7 b_index 阅读全文
posted @ 2020-02-23 13:44 Sempron2800+ 阅读(154) 评论(0) 推荐(0)
leetcode1357
摘要:1 class Cashier: 2 def __init__(self, n: int, discount: int, products: 'List[int]', prices: 'List[int]'): 3 self.customer_num = 0 4 self.dic = {} 5 m 阅读全文
posted @ 2020-02-23 13:08 Sempron2800+ 阅读(150) 评论(0) 推荐(0)
leetcode1356
摘要:1 import collections 2 class Solution: 3 def countBitOnes(self,num): 4 count = 0 5 for i in range(14): 6 if num & 1 == 1: 7 count += 1 8 num >>= 1 9 r 阅读全文
posted @ 2020-02-23 07:35 Sempron2800+ 阅读(154) 评论(0) 推荐(0)
leetcode1353
摘要:1 class Solution: 2 def maxEvents(self, events: 'List[List[int]]') -> int: 3 events.sort(key=lambda item: (item[1], item[0])) 4 days = set() 5 for sta 阅读全文
posted @ 2020-02-16 19:00 Sempron2800+ 阅读(181) 评论(0) 推荐(0)
leetcode1352
摘要:1 class ProductOfNumbers: 2 def __init__(self): 3 self.matrix = [] 4 self.preproducts = [] 5 self.length = 0 6 self.zeros = set() 7 8 def add(self, nu 阅读全文
posted @ 2020-02-16 14:34 Sempron2800+ 阅读(158) 评论(0) 推荐(0)
leetcode1351
摘要:1 import bisect 2 class Solution: 3 def countNegatives(self, grid: 'List[List[int]]') -> int: 4 m = len(grid) 5 n = len(grid[0]) 6 sums = 0 7 for i in 阅读全文
posted @ 2020-02-16 13:39 Sempron2800+ 阅读(182) 评论(0) 推荐(0)
leetcode1348
摘要:1 import bisect 2 class TweetCounts: 3 def __init__(self): 4 self.records = {} 5 6 def recordTweet(self, tweetName: str, time: int) -> None: 7 if twee 阅读全文
posted @ 2020-02-09 14:27 Sempron2800+ 阅读(200) 评论(0) 推荐(0)
leetcode1347
摘要:1 class Solution: 2 def minSteps(self, s: str, t: str) -> int: 3 n = len(s) 4 dic1 = {} 5 for i in range(n): 6 cur = s[i] 7 if cur not in dic1: 8 dic1 阅读全文
posted @ 2020-02-09 12:05 Sempron2800+ 阅读(137) 评论(0) 推荐(0)
leetcode1346
摘要:1 class Solution: 2 def checkIfExist(self, arr: List[int]) -> bool: 3 s = set() 4 n = len(arr) 5 for i in range(n): 6 cur = arr[i] 7 if cur in s: 8 re 阅读全文
posted @ 2020-02-09 12:04 Sempron2800+ 阅读(163) 评论(0) 推荐(0)
leetcode1344
摘要:1 class Solution: 2 def angleClock(self, hour: int, minutes: int) -> float: 3 m_angle = minutes * 6 4 h_angle = (hour + minutes / 60) * 6 * 5 if hour 阅读全文
posted @ 2020-02-09 09:40 Sempron2800+ 阅读(204) 评论(0) 推荐(0)
leetcode1343
摘要:1 class Solution: 2 def numOfSubarrays(self, arr: List[int], k: int, threshold: int) -> int: 3 n = len(arr) 4 count = 0 5 sums = sum(arr[:k]) 6 avg = 阅读全文
posted @ 2020-02-09 09:27 Sempron2800+ 阅读(152) 评论(0) 推荐(0)
leetcode1342
摘要:1 class Solution: 2 def numberOfSteps (self, num: int) -> int: 3 count = 0 4 while num != 0: 5 count += 1 6 if num & 1 == 1: 7 num -= 1 8 else: 9 num 阅读全文
posted @ 2020-02-09 09:07 Sempron2800+ 阅读(154) 评论(0) 推荐(0)
leetcode1339
摘要:1 class Solution: 2 def __init__(self): 3 self.subTrees = [] 4 self.sums = 0 5 self.memo = {} 6 def preOrder(self,root): 7 if root != None: 8 self.sum 阅读全文
posted @ 2020-02-02 12:58 Sempron2800+ 阅读(242) 评论(0) 推荐(0)
leetcode1338
摘要:1 class Solution: 2 def minSetSize(self, arr: 'List[int]') -> int: 3 m = len(arr) 4 dic = {} 5 for i in range(m): 6 if arr[i] in dic: 7 dic[arr[i]] += 阅读全文
posted @ 2020-02-02 12:54 Sempron2800+ 阅读(178) 评论(0) 推荐(0)
leetcode1337
摘要:1 class Solution: 2 def kWeakestRows(self, mat: 'List[List[int]]', k: int) -> 'List[int]': 3 m = len(mat) 4 n = len(mat[0]) 5 counter = [0] * m 6 for 阅读全文
posted @ 2020-02-02 12:53 Sempron2800+ 阅读(158) 评论(0) 推荐(0)