上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 114 下一页
摘要: 1 class segTree: 2 def __init__(self,nums): 3 n = len(nums) 4 for i in range(1,31): 5 low,high = 2 ** (i-1),2 ** i 6 if n > low and n < high: 7 fillze 阅读全文
posted @ 2020-04-07 13:40 Sempron2800+ 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 1 class NumMatrix: 2 def __init__(self, matrix: 'List[List[int]]'): 3 self.matrix = matrix 4 m,n = 0,0 5 m = len(matrix) 6 if m > 0: 7 n = len(matrix[ 阅读全文
posted @ 2020-04-07 09:41 Sempron2800+ 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution(object): 2 def jump(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 ln = len(nums) 8 curr = 0 9 last = 0 10 step = 0 阅读全文
posted @ 2020-04-06 10:10 Sempron2800+ 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 第一种方案,使用堆: 1 from heapq import heappush, heappop 2 class Solution: 3 def longestDiverseString(self, a: int, b: int, c: int) -> str: 4 max_heap = [] 5 阅读全文
posted @ 2020-04-06 08:50 Sempron2800+ 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool: 3 if t == 0 and len(set(nums)) == len(nums): 4 r 阅读全文
posted @ 2020-04-06 08:48 Sempron2800+ 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def hIndex(self, citations): 3 citations_len = len(citations) 4 if citations_len<=0: 5 return 0 6 low = 0 7 high = citations_len-1 阅读全文
posted @ 2020-04-06 08:44 Sempron2800+ 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def hIndex(self, citations: 'List[int]') -> int: 3 n = len(citations) 4 if n == 0: 5 return 0 6 citations = sorted(citations,rever 阅读全文
posted @ 2020-04-06 08:41 Sempron2800+ 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 1 class PeekingIterator: 2 def __init__(self, iterator): 3 self.iterator = iterator 4 self.head = iterator.next() 5 6 def peek(self): 7 return self.he 阅读全文
posted @ 2020-04-06 08:16 Sempron2800+ 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def convertInt(self,s): 3 n = len(s) 4 basenum = 0 5 p = 0 6 for i in range(n-1,-1,-1): 7 basenum += int(s[i]) * (2 ** p) 8 p += 1 阅读全文
posted @ 2020-04-05 12:57 Sempron2800+ 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def minSubsequence(self, nums: 'List[int]') -> 'List[int]': 3 nums = sorted(nums,reverse=True) 4 n = len(nums) 5 if n == 1: 6 retu 阅读全文
posted @ 2020-04-05 12:55 Sempron2800+ 阅读(159) 评论(0) 推荐(0) 编辑
上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 114 下一页