摘要: 题目描述: 第一次提交:超时 O(N**N) class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> List[str]: if not wordDict:return [] res = [] min_len,max_l 阅读全文
posted @ 2019-10-21 21:28 oldby 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 题77 回溯: class Solution: def combine(self, n: int, k: int) -> List[List[int]]: res = [] def backtrack(i,temp_list): if len(temp_list)==k: res.append(te 阅读全文
posted @ 2019-10-21 19:50 oldby 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法: class Solution: def maximizeSweetness(self, A: List[int], K: int) -> int: def possible(x): k, temp = 0, 0 for a in A: temp += a if temp >= x 阅读全文
posted @ 2019-10-21 14:01 oldby 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 二维dp: class Solution: def probabilityOfHeads(self, prob: List[float], target: int) -> float: dp = [[0 for _ in range(target+1)] for _ in range(l 阅读全文
posted @ 2019-10-21 13:16 oldby 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def minAvailableDuration(self, slots1: List[List[int]], slots2: List[List[int]], duration: int) -> List[int]: res = [] i, 阅读全文
posted @ 2019-10-21 11:45 oldby 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def missingNumber(self, arr: List[int]) -> int: if len(arr) == 2: return arr[0] + (arr[1] - arr[0]) //2 if len(set(arr)) 阅读全文
posted @ 2019-10-21 11:29 oldby 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 方法: class Solution: def jobScheduling(self, startTime: List[int], endTime: List[int], profit: List[int]) -> int: idx=[i for i in range(len(startTime)) 阅读全文
posted @ 2019-10-21 11:01 oldby 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法: 另: class Solution: def balancedString(self, s: str) -> int: n, req = len(s), len(s) // 4 c_all = collections.Counter(s) c_cur = collections. 阅读全文
posted @ 2019-10-21 09:56 oldby 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己的提交: class Solution: def removeSubfolders(self, folder: List[str]) -> List[str]: d = {} res = [] for f in folder: l_f = f.split("/")[1:] node 阅读全文
posted @ 2019-10-21 09:22 oldby 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 自己的提交: class Solution: def checkStraightLine(self, coordinates: List[List[int]]) -> bool: if not coordinates: return False if len(coordinates) <= 2: r 阅读全文
posted @ 2019-10-21 09:06 oldby 阅读(133) 评论(0) 推荐(0) 编辑