LeetCode——Backtracking 末蓝、 2023-06-19 09:38 31阅读 0赞 # Backtracking # -------------------- ## 目录 ## 1. Backtracking 2. 数字键盘组合 3. IP 地址划分 4. 在矩阵中寻找字符串 5. 输出二叉树中所有从根到叶子的路径 6. 排列 7. 含有相同元素求排列 8. 组合 9. 组合求和 10. 含有相同元素的组合求和 11. 1-9 数字的组合求和 12. 子集 13. 含有相同元素求子集 14. 分割字符串使得每个部分都是回文数 15. 数独 16. N皇后 -------------------- ### 1. Backtracking ### Backtracking(回溯)属于 DFS。 普通 DFS 主要用在`可达性问题`,这种问题只需要执行到特点的位置然后返回即可。 而 Backtracking 主要用于求解 `排列组合` 问题,例如有 \{ ‘a’,‘b’,‘c’ \} 三个字符,求解所有由这三个字符排列得到的字符串,这种问题在执行到特定的位置返回之后还会继续执行求解过程。 因为 Backtracking 不是立即返回,而要继续求解,因此在程序实现时,需要注意对元素的标记问题: 在访问一个新元素进入新的递归调用时,需要将新元素标记为已经访问,这样才能在继续递归调用时不用重复访问该元素; 但是在递归返回时,需要将元素标记为未访问,因为只需要保证在一个递归链中不同时访问一个元素,可以访问已经访问过但是不在当前递归链中的元素。 -------------------- ### 2. 数字键盘组合 ### [https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number][https_leetcode-cn.com_problems_letter-combinations-of-a-phone-number] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70] private static final String[] KEYS = { "","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; public List<String> letterCombinations(String digits){ List<String> combinations = new ArrayList<>(); if (digits==null||digits.length()==0){ return combinations; } doCombination(new StringBuilder(),combinations,digits); return combinations; } private void doCombination(StringBuilder prefix, List<String> combinations, final String digits) { if (prefix.length()==digits.length()){ combinations.add(prefix.toString()); return; } int num = digits.charAt(prefix.length()) - '0'; String key = KEYS[num]; for (char c : key.toCharArray()) { prefix.append(c); doCombination(prefix,combinations,digits); prefix.deleteCharAt(prefix.length()-1); } } -------------------- ### 3. IP 地址划分 ### [https://leetcode-cn.com/problems/restore-ip-addresses][https_leetcode-cn.com_problems_restore-ip-addresses] ![在这里插入图片描述][20191205171051876.png] public List<String> restoreIpAddresses(String s) { List<String> addresses = new ArrayList<>(); StringBuilder tempAddress = new StringBuilder(); doRestore(0, tempAddress, addresses, s); return addresses; } private void doRestore(int k, StringBuilder tempAddress, List<String> addresses, String s) { //整体分成4个段 if (k == 4 || s.length() == 0) { if (k == 4 && s.length() == 0) { addresses.add(tempAddress.toString()); } return; } //每个段的判断 for (int i = 0; i < s.length() && i <= 2; i++) { if (i != 0 && s.charAt(0) == '0') { break; } String part = s.substring(0, i + 1); if (Integer.valueOf(part) <= 255) { if (tempAddress.length() != 0) { part = "." + part; } tempAddress.append(part); doRestore(k + 1, tempAddress, addresses, s.substring(i + 1)); tempAddress.delete(tempAddress.length() - part.length(), tempAddress.length()); } } } -------------------- ### 4. 在矩阵中寻找字符串 ### [https://leetcode-cn.com/problems/word-search][https_leetcode-cn.com_problems_word-search] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 1] 题目描述:给定一个二维网格和一个单词,找出该单词是否存在于网格中。 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母不允许被重复使用。 private final static int[][] direction = { { 1, 0}, { -1, 0}, { 0, 1}, { 0, -1}}; private int m, n; public boolean exist(char[][] board, String word) { if (word == null || word.length() == 0) { return true; } if (board == null || board.length == 0 || board[0].length == 0) { return false; } m = board.length; n = board[0].length; boolean[][] visited = new boolean[m][n]; for (int r = 0; r < m; r++) { for (int c = 0; c < n; c++) { if (backtracking(0, r, c, visited, board, word)) { return true; } } } return false; } private boolean backtracking(int curLen, int r, int c, boolean[][] visited, final char[][] board, final String word) { if (curLen == word.length()) { return true; } if (r < 0 || r >= m || c < 0 || c >= n || board[r][c] != word.charAt(curLen) || visited[r][c]) { return false; } visited[r][c] = true; for (int[] d : direction) { if (backtracking(curLen + 1, r + d[0], c + d[1], visited, board, word)) { return true; } } visited[r][c] = false; return false; } -------------------- ### 5. 输出二叉树中所有从根到叶子的路径 ### [https://leetcode.com/problems/binary-tree-paths][https_leetcode.com_problems_binary-tree-paths] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 2] public static class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } public List<String> binaryTreePaths(TreeNode root) { List<String> paths = new ArrayList<>(); if (root == null) { return paths; } List<Integer> values = new ArrayList<>(); backtracking(root, values, paths); return paths; } private void backtracking(TreeNode node, List<Integer> values, List<String> paths) { if (node == null) { return; } values.add(node.val); if (isLeaf(node)) { paths.add(buildPath(values)); } else { backtracking(node.left, values, paths); backtracking(node.right, values, paths); } values.remove(values.size() - 1); } private String buildPath(List<Integer> values) { StringBuilder str = new StringBuilder(); for (int i = 0; i < values.size(); i++) { str.append(values.get(i)); if (i != values.size() - 1) { str.append("->"); } } return str.toString(); } private boolean isLeaf(TreeNode node) { return node.left == null && node.right == null; } -------------------- ### 6. 排列 ### ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 3] 题目描述:给定一个没有重复数字的序列,返回其所有可能的全排列。 public List<List<Integer>> permute(int[] nums) { List<List<Integer>> permutes = new ArrayList<>(); List<Integer> permuteList = new ArrayList<>(); boolean[] hasVisited = new boolean[nums.length]; backtracking(permuteList, permutes, hasVisited, nums); return permutes; } private void backtracking(List<Integer> permuteList, List<List<Integer>> permutes, boolean[] visited, int[] nums) { if (permuteList.size() == nums.length) { permutes.add(new ArrayList<>(permuteList)); //重新构造一个 List return; } for (int i = 0; i < visited.length; i++) { if (visited[i]) { continue; } visited[i] = true; permuteList.add(nums[i]); backtracking(permuteList, permutes, visited, nums); permuteList.remove(permuteList.size() - 1); visited[i] = false; } } -------------------- ### 7. 含有相同元素求排列 ### ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 4] 题目描述:数组元素可能含有相同的元素,进行排列时就有可能出现重复的排列,要求重复的排列只返回一个。 在实现上,和 Permutations 不同的是要先排序,然后在添加一个元素时,判断这个元素是否等于前一个元素,如果等于,并且前一个元素还未访问,那么就跳过这个元素。 public List<List<Integer>> permuteUnique(int[] nums) { List<List<Integer>> permutes = new ArrayList<>(); List<Integer> permuteList = new ArrayList<>(); Arrays.sort(nums); boolean[] hasVisited = new boolean[nums.length]; backtracking(permuteList, permutes, hasVisited, nums); return permutes; } private void backtracking(List<Integer> permuteList, List<List<Integer>> permutes, boolean[] visited, int[] nums) { if (permuteList.size() == nums.length) { permutes.add(new ArrayList<>(permuteList)); return; } for (int i = 0; i < visited.length; i++) { if (i != 0 && nums[i] == nums[i - 1] && !visited[i - 1]) { continue; //防止重复 } if (visited[i]) { continue; } visited[i] = true; permuteList.add(nums[i]); backtracking(permuteList, permutes, visited, nums); permuteList.remove(permuteList.size() - 1); visited[i] = false; } } -------------------- ### 8. 组合 ### [https://leetcode-cn.com/problems/combinations][https_leetcode-cn.com_problems_combinations] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 5] public List<List<Integer>> combine(int n, int k) { List<List<Integer>> combinations = new ArrayList<>(); List<Integer> combineList = new ArrayList<>(); backtracking(combineList, combinations, 1, k, n); return combinations; } private void backtracking(List<Integer> combineList, List<List<Integer>> combinations, int start, int k, int n) { if (k == 0) { combinations.add(new ArrayList<>(combineList)); return; } for (int i = start; i <= n - k + 1; i++) { combineList.add(i); backtracking(combineList, combinations, i + 1, k - 1, n); combineList.remove(combineList.size() - 1); } } -------------------- ### 9. 组合求和 ### [https://leetcode.com/problems/combination-sum/description/][https_leetcode.com_problems_combination-sum_description] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 6] 题目描述:给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的数字可以无限制重复被选取。 说明: * 所有数字(包括 target)都是正整数。 * 解集不能包含重复的组合。 public List<List<Integer>> combiationSum(int[] candidates, int target) { List<List<Integer>> combinations = new ArrayList<>(); backtracking(new ArrayList<>(), combinations, 0, target, candidates); return combinations; } private void backtracking(ArrayList<Integer> tempCombination, List<List<Integer>> combinations, int start, int target, int[] candidates) { if (target == 0) { combinations.add(new ArrayList<>(tempCombination)); return; } for (int i = start; i < candidates.length; i++) { if (candidates[i] <= target) { tempCombination.add(candidates[i]); backtracking(tempCombination, combinations, i, target - candidates[i], candidates); tempCombination.remove(tempCombination.size() - 1); } } } -------------------- ### 10. 含有相同元素的组合求和 ### [https://leetcode.com/problems/combination-sum-ii/description/][https_leetcode.com_problems_combination-sum-ii_description] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 7] 题目描述:给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数字在每个组合中只能使用一次。 说明: * 所有数字(包括目标数)都是正整数。 * 解集不能包含重复的组合。 public List<List<Integer>> combinationSum2(int[] candidates, int target) { List<List<Integer>> combinations = new ArrayList<>(); Arrays.sort(candidates); backtracking(combinations, new ArrayList<>(), new boolean[candidates.length], 0, target, candidates); return combinations; } private void backtracking(List<List<Integer>> combinations, List<Integer> combinationList, boolean[] visited, int start, int target, int[] candidates) { if (target == 0) { combinations.add(new ArrayList<>(combinationList)); return; } for (int i = start; i < candidates.length; i++) { if (i != 0 && candidates[i] == candidates[i - 1] && !visited[i - 1]) { continue; } if (candidates[i] <= target) { combinationList.add(candidates[i]); visited[i] = true; backtracking(combinations, combinationList, visited, i + 1, target - candidates[i], candidates); visited[i] = false; combinationList.remove(combinationList.size() - 1); } } } -------------------- ### 11. 1-9 数字的组合求和 ### [https://leetcode.com/problems/combination-sum-iii/description/][https_leetcode.com_problems_combination-sum-iii_description] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 8] 题目描述:找出所有相加之和为 n 的 k 个数的组合。组合中只允许含有 1 - 9 的正整数,并且每种组合中不存在重复的数字。 说明: * 所有数字都是正整数。 * 解集不能包含重复的组合。 public List<List<Integer>> combinationSum3(int k, int n) { List<List<Integer>> combinations = new ArrayList<>(); List<Integer> combinationList = new ArrayList<>(); backtracking(combinationList, combinations, 1, k, n); return combinations; } private void backtracking(List<Integer> combinationList, List<List<Integer>> combinations, int start, int k, int target) { if (k == 0 && target == 0) { combinations.add(new ArrayList<>(combinationList)); return; } if (k == 0 || target == 0) { return; } for (int i = start; i <= 9; i++) { combinationList.add(i); backtracking(combinationList, combinations, i + 1, k - 1, target - i); combinationList.remove(combinationList.size() - 1); } } -------------------- ### 12. 子集 ### [https://leetcode.com/problems/subsets-ii/description/][https_leetcode.com_problems_subsets-ii_description] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 9] 题目描述:找出集合的所有子集,子集不能重复,\[1, 2\] 和 \[2, 1\] 这种子集算重复 public List<List<Integer>> subsets(int[] nums) { List<List<Integer>> subsets = new ArrayList<>(); List<Integer> tempSubset = new ArrayList<>(); for (int size = 0; size <= nums.length; size++) { backtracking(subsets, tempSubset, size, 0, nums); } return subsets; } private void backtracking(List<List<Integer>> subsets, List<Integer> tempSubset, int size, int start, int[] nums) { if (size == 0) { subsets.add(new ArrayList<>(tempSubset)); } for (int i = start; i < nums.length; i++) { tempSubset.add(nums[i]); backtracking(subsets, tempSubset, size - 1, i + 1, nums); tempSubset.remove(tempSubset.size() - 1); } } -------------------- ### 13. 含有相同元素求子集 ### ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 10] 题目描述:给定一个可能包含重复数的整数集合,返回所有可能的子集(幂集)。 注意:解决方案集不能包含重复的子集。 public List<List<Integer>> subsets(int[] nums) { List<List<Integer>> subsets = new ArrayList<>(); List<Integer> tempSubset = new ArrayList<>(); for (int size = 0; size <= nums.length; size++) { backtracking(subsets, tempSubset, size, 0, nums); } return subsets; } private void backtracking(List<List<Integer>> subsets, List<Integer> tempSubset, int size, int start, int[] nums) { if (size == 0) { subsets.add(new ArrayList<>(tempSubset)); } for (int i = start; i < nums.length; i++) { tempSubset.add(nums[i]); backtracking(subsets, tempSubset, size - 1, i + 1, nums); tempSubset.remove(tempSubset.size() - 1); } } -------------------- ### 14. 分割字符串使得每个部分都是回文数 ### [https://leetcode-cn.com/problems/palindrome-partitioning][https_leetcode-cn.com_problems_palindrome-partitioning] ![在这里插入图片描述][20191208122902703.png] 题目描述:给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。 返回 s 所有可能的分割方案。 public List<List<String>> partition(String s) { List<List<String>> partitions = new ArrayList<>(); List<String> tempPartition = new ArrayList<>(); doPartition(s, partitions, tempPartition); return partitions; } private void doPartition(String s, List<List<String>> partitions, List<String> tempPartition) { if (s.length() == 0) { partitions.add(new ArrayList<>(tempPartition)); return; } for (int i = 0; i < s.length(); i++) { if (isPalindrome(s, 0, i)) { tempPartition.add(s.substring(0, i + 1)); doPartition(s.substring(i + 1), partitions, tempPartition); tempPartition.remove(tempPartition.size() - 1); } } } private boolean isPalindrome(String s, int begin, int end) { while (begin < end) { if (s.charAt(begin++) != s.charAt(end--)) { return false; } } return true; } -------------------- ### 15. 数独 ### [https://leetcode-cn.com/problems/sudoku-solver/solution/jie-shu-du-by-leetcode/][https_leetcode-cn.com_problems_sudoku-solver_solution_jie-shu-du-by-leetcode] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 11] ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 12] 题目描述:编写一个程序,通过已填充的空格来解决数独问题。 一个数独的解法需遵循如下规则: * 数字 1-9 在每一行只能出现一次。 * 数字 1-9 在每一列只能出现一次。 * 数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。 * 空白格用 ‘.’ 表示。 private boolean[][] rowsUsed = new boolean[9][10]; private boolean[][] colsUsed = new boolean[9][10]; private boolean[][] cubesUsed = new boolean[9][10]; private char[][] board; public void solveSudoku(char[][] board) { this.board = board; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (board[i][j] == '.') { continue; } int num = board[i][j] - '0'; rowsUsed[i][num] = true; colsUsed[j][num] = true; cubesUsed[cubes(i, j)][num] = true; } backtracking(0, 0); } } private boolean backtracking(int row, int col) { while (row < 9 && board[row][col] != '.') { row = col == 8 ? row + 1 : row; col = col == 8 ? 0 : col + 1; } if (row == 9) { return true; } for (int num = 1; num <= 9; num++) { if (rowsUsed[row][num] || colsUsed[col][num] || cubesUsed[cubes(row, col)][num]) { continue; } rowsUsed[row][num] = colsUsed[col][num] = cubesUsed[cubes(row, col)][num] == true; board[row][col] = (char) (num + '0'); if (backtracking(row, col)) { return true; } board[row][col] = '.'; rowsUsed[row][num] = colsUsed[col][num] = cubesUsed[cubes(row, col)][num] == false; } return false; } private int cubes(int i, int j) { int r = i / 3; int c = j / 3; return r * 3 + c; } -------------------- ### 16. N皇后 ### [https://leetcode-cn.com/problems/n-queens/solution/nhuang-hou-by-leetcode/][https_leetcode-cn.com_problems_n-queens_solution_nhuang-hou-by-leetcode]![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 13] 题目描述:n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。 ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 14] 上图为 8 皇后问题的一种解法。 给定一个整数 n,返回所有不同的 n 皇后问题的解决方案。 每一种解法包含一个明确的 n 皇后问题的棋子放置方案,该方案中 ‘Q’ 和 ‘.’ 分别代表了皇后和空位。 private List<List<String>> solutions; private char[][] nQueues; private boolean[] colUsed; private boolean[] diagonals45Used; private boolean[] diagonals135Used; private int n; public List<List<String>> solveNQueues(int n) { solutions = new ArrayList<>(); nQueues = new char[n][n]; for (int i = 0; i < n; i++) { Arrays.fill(nQueues[i], '.'); } colUsed = new boolean[n]; diagonals45Used = new boolean[2 * n - 1]; diagonals135Used = new boolean[2 * n - 1]; this.n = n; backtracking(0); return solutions; } private void backtracking(int row) { if (row == n) { List<String> list = new ArrayList<>(); for (char[] chars : nQueues) { list.add(new String(chars)); } solutions.add(list); return; } for (int col = 0; col < n; col++) { int diagonals45Idx = row + col; int diagonals135Idx = n - 1 - (row - col); if (colUsed[col] || diagonals45Used[diagonals45Idx] || diagonals135Used[diagonals135Idx]) { continue; } nQueues[row][col] = 'Q'; colUsed[col] = diagonals45Used[diagonals45Idx] = diagonals135Used[diagonals135Idx] = true; backtracking(row + 1); colUsed[col] = diagonals45Used[diagonals45Idx] = diagonals135Used[diagonals135Idx] = false; nQueues[row][col] = '.'; } } [https_leetcode-cn.com_problems_letter-combinations-of-a-phone-number]: https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/description/?utm_source=LCUS&utm_medium=ip_redirect_q_uns&utm_campaign=transfer2china [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70]: https://img-blog.csdnimg.cn/20191205151658204.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode-cn.com_problems_restore-ip-addresses]: https://leetcode-cn.com/problems/restore-ip-addresses/description/?utm_source=LCUS&utm_medium=ip_redirect_q_uns&utm_campaign=transfer2china [20191205171051876.png]: https://img-blog.csdnimg.cn/20191205171051876.png [https_leetcode-cn.com_problems_word-search]: https://leetcode-cn.com/problems/word-search/description/?utm_source=LCUS&utm_medium=ip_redirect_q_uns&utm_campaign=transfer2china [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 1]: https://img-blog.csdnimg.cn/20191206104830370.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode.com_problems_binary-tree-paths]: https://leetcode.com/problems/binary-tree-paths/description/ [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 2]: https://img-blog.csdnimg.cn/20191206113106221.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 3]: https://img-blog.csdnimg.cn/20191206171103924.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 4]: https://img-blog.csdnimg.cn/20191206180015442.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode-cn.com_problems_combinations]: https://leetcode-cn.com/problems/combinations/description/?utm_source=LCUS&utm_medium=ip_redirect_q_uns&utm_campaign=transfer2china [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 5]: https://img-blog.csdnimg.cn/2019120710202313.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode.com_problems_combination-sum_description]: https://leetcode.com/problems/combination-sum/description/ [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 6]: https://img-blog.csdnimg.cn/20191207110956729.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode.com_problems_combination-sum-ii_description]: https://leetcode.com/problems/combination-sum-ii/description/ [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 7]: https://img-blog.csdnimg.cn/20191207143449937.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode.com_problems_combination-sum-iii_description]: https://leetcode.com/problems/combination-sum-iii/description/ [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 8]: https://img-blog.csdnimg.cn/20191207174333851.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode.com_problems_subsets-ii_description]: https://leetcode.com/problems/subsets-ii/description/ [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 9]: https://img-blog.csdnimg.cn/20191207175512337.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 10]: https://img-blog.csdnimg.cn/20191208121055159.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode-cn.com_problems_palindrome-partitioning]: https://leetcode-cn.com/problems/palindrome-partitioning/description/?utm_source=LCUS&utm_medium=ip_redirect_q_uns&utm_campaign=transfer2china [20191208122902703.png]: https://img-blog.csdnimg.cn/20191208122902703.png [https_leetcode-cn.com_problems_sudoku-solver_solution_jie-shu-du-by-leetcode]: https://leetcode-cn.com/problems/sudoku-solver/solution/jie-shu-du-by-leetcode/ [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 11]: https://img-blog.csdnimg.cn/20191208155709611.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 12]: https://img-blog.csdnimg.cn/20191208155809104.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [https_leetcode-cn.com_problems_n-queens_solution_nhuang-hou-by-leetcode]: https://leetcode-cn.com/problems/n-queens/solution/nhuang-hou-by-leetcode/ [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 13]: https://img-blog.csdnimg.cn/20191208195933354.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70 [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA_size_16_color_FFFFFF_t_70 14]: https://img-blog.csdnimg.cn/20191208200008967.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTkxMDY5NA==,size_16,color_FFFFFF,t_70
还没有评论,来说两句吧...