上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 47 下一页
摘要: 题目描述: 方法一: import collections class Solution: def groupAnagrams(self, strs) : ans = collections.defaultdict(list) for s in strs: ans[tuple(sorted(s))] 阅读全文
posted @ 2019-07-12 12:13 oldby 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:先转置再反转 class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ n 阅读全文
posted @ 2019-07-12 11:03 oldby 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交: class Solution: def addStrings(self, num1: str, num2: str) -> str: if len(num1) < len(num2): num1,num2 = num2,num1 num1 = [_ for _ in num 阅读全文
posted @ 2019-07-12 10:25 oldby 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 恢复内容开始 题目描述: 方法一:O(n2) class Solution: def multiply(self, num1: str, num2: str) -> str: def str2int(s): return ord(s) - ord("0") res = 0 num1,num2 = n 阅读全文
posted @ 2019-07-12 09:56 oldby 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:回溯 class Solution: def subsetsWithDup(self, nums: List[int]) -> List[List[int]]: nums.sort() if not nums: return [] n = len(nums) res = [] d 阅读全文
posted @ 2019-07-11 17:46 oldby 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:回溯 class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: if not sum: return [] res = [] n = len(nums) def backtrack(idx,tem 阅读全文
posted @ 2019-07-11 17:31 oldby 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:回溯 class Solution: def permuteUnique(self, nums: List[int]) -> List[List[int]]: #nums = nums.sort() n = len(nums) res = [] def backtrack(num 阅读全文
posted @ 2019-07-11 16:48 oldby 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:回溯 class Solution: def permute(self, nums): n = len(nums) res = [] def helper2(nums, temp_list, length): if length == n: res.append(temp_lis 阅读全文
posted @ 2019-07-11 15:25 oldby 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:回溯 class Solution: def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]: candidates.sort() res = [] def backtrac 阅读全文
posted @ 2019-07-11 10:37 oldby 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:O(1) O(1) class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: rows = [{} for i in range(9)] columns = [{} for i in rang 阅读全文
posted @ 2019-07-10 20:29 oldby 阅读(211) 评论(0) 推荐(0) 编辑
上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 47 下一页