上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 51 下一页
摘要: 方法一:二分查找。 class Solution(object): # 二分法 def countNegatives(self, grid): """ :type grid: List[List[int]] :rtype: int """ ans = 0 for nums in grid: if n 阅读全文
posted @ 2020-06-08 14:03 人间烟火地三鲜 阅读(200) 评论(0) 推荐(0)
摘要: class Solution(object): def kWeakestRows(self, mat, k): """ :type mat: List[List[int]] :type k: int :rtype: List[int] """ power = [sum(line) for line 阅读全文
posted @ 2020-06-08 14:01 人间烟火地三鲜 阅读(214) 评论(0) 推荐(0)
摘要: class Solution(object): def maxDepthAfterSplit(self, seq): """ :type seq: str :rtype: List[int] """ res = [] if not seq: return res depth, max_depth = 阅读全文
posted @ 2020-06-08 13:58 人间烟火地三鲜 阅读(155) 评论(0) 推荐(0)
摘要: 思路:二分法。 class Solution(object): def nextGreatestLetter(self, letters, target): letters = list(set(letters)) letters.sort() if target in letters: index 阅读全文
posted @ 2020-06-08 13:56 人间烟火地三鲜 阅读(124) 评论(0) 推荐(0)
摘要: class Solution(object): def findRadius(self, houses, heaters): """ :type houses: List[int] :type heaters: List[int] :rtype: int """ ans = [] heaters.s 阅读全文
posted @ 2020-06-08 13:53 人间烟火地三鲜 阅读(174) 评论(0) 推荐(0)
摘要: class Solution(object): def arrangeCoins(self, n): """ :type n: int :rtype: int """ return int(2 ** 0.5 * (n + 1 / 8) ** 0.5 - 1 / 2) if __name__ == ' 阅读全文
posted @ 2020-06-08 13:51 人间烟火地三鲜 阅读(120) 评论(0) 推荐(0)
摘要: class Solution(object): def isSubsequence(self, s, t): """ :type s: str :type t: str :rtype: bool """ if len(s) > len(t): return False elif len(s) == 阅读全文
posted @ 2020-06-08 13:49 人间烟火地三鲜 阅读(138) 评论(0) 推荐(0)
摘要: 方法一:二分查找。 class Solution(object): # 二分查找 def kthSmallest(self, matrix, k): """ :type matrix: List[List[int]] :type k: int :rtype: int """ n = len(matr 阅读全文
posted @ 2020-06-08 13:47 人间烟火地三鲜 阅读(176) 评论(0) 推荐(0)
摘要: 题意:即nums长为n+1,里面的元素值范围:[1,n],有且仅有一个重复值,但该值可以重复多次,所以[1,n]有的数可以不在nums里。 方法一:二分查找。 class Solution(object): # 二分查找 def findDuplicate(self, nums): low = 1 阅读全文
posted @ 2020-06-08 13:44 人间烟火地三鲜 阅读(171) 评论(0) 推荐(0)
摘要: class Solution(object): def searchRange(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ # 处理target不在nums中的情况 if 阅读全文
posted @ 2020-06-08 13:36 人间烟火地三鲜 阅读(108) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 51 下一页