摘要: 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+ 阅读(160) 评论(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+ 阅读(111) 评论(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+ 阅读(102) 评论(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) 编辑