摘要: 当给定一个数组,要想到一些点: 1、是否已排序 2、是否有重复数字 3、是否有负数 一:常规二分搜索 def bi_search_iter(alist, item): left, right = 0, len(alist) - 1 while left <= right: mid = (left + 阅读全文
posted @ 2019-11-25 21:58 oldby 阅读(1225) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def numWays(self, steps: int, arrLen: int) -> int: l = min(steps,arrLen) dp = [0] * l dp[0] = 1 MOD = 10 ** 9 + 7 for ste 阅读全文
posted @ 2019-11-25 17:11 oldby 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def suggestedProducts(self, products: List[str], searchWord: str) -> List[List[str]]: products.sort() res = [] for i in r 阅读全文
posted @ 2019-11-25 16:49 oldby 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def countServers(self, grid: List[List[int]]) -> int: from collections import Counter m,n = len(grid),len(grid[0]) falg = 阅读全文
posted @ 2019-11-25 16:35 oldby 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的解: class Solution: def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int: res = 0 n = len(points) if n < 2: return res pre = poin 阅读全文
posted @ 2019-11-25 16:29 oldby 阅读(111) 评论(0) 推荐(0) 编辑