摘要: 题17: 方法一:回溯 class Solution: def letterCombinations(self, digits: str) -> List[str]: res = [] dic ={"2":"abc","3":"def","4":"ghi","5":"jkl","6":"mno"," 阅读全文
posted @ 2019-10-18 20:09 oldby 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:回溯 class Solution: def totalNQueens(self, n: int) -> int: def backtrack(i,tmp,col,z_diagonal,i_diagonal): if i == n: nonlocal res res += 1 r 阅读全文
posted @ 2019-10-18 19:52 oldby 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交:回溯: class Solution: def solveNQueens(self, n: int) -> List[List[str]]: def sub(string, p, c): new = [s for s in string] new[p] = c return 阅读全文
posted @ 2019-10-18 12:52 oldby 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 回溯:超时 class Solution: def isMatch(self, s: str, p: str) -> bool: if not p: return not bool(s) if not s and p[0] == "*": return self.isMatch(s,p[ 阅读全文
posted @ 2019-10-18 10:43 oldby 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 自己提交:未找出错(留坑) class Solution: def solveSudoku(self, board: List[List[str]]) -> None: def helper(i,j): if i==j==8: return True if i==8: print(i,j 阅读全文
posted @ 2019-10-18 09:21 oldby 阅读(396) 评论(0) 推荐(0) 编辑