
Backtracking
Peng_maple
这个作者很懒,什么都没留下…
展开
-
[LeetCode] 37. Sudoku Solver
Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:Each of the digits 1-9 must occur exactly once in each ro...原创 2019-03-29 14:14:21 · 186 阅读 · 0 评论 -
[LeetCode] 22. Generate Parentheses
Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[“((()))”,“(()())”,“(())()...原创 2019-03-27 17:16:21 · 140 阅读 · 0 评论 -
[LeetCode] 17. Letter Combinations of a Phone Number
Letter Combinations of a Phone NumberGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just ...原创 2019-03-27 15:44:43 · 257 阅读 · 0 评论 -
[LeetCode] 46. Permutations
PermutationsGiven a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]解析生成全排列。解法1:DFS用一个...原创 2019-04-01 16:39:43 · 152 阅读 · 0 评论 -
[LeetCode] 47. Permutations 2
Permutations 2Given a collection of numbers that might contain duplicates, return all possible unique permutations.Example:Input: [1,1,2]Output:[[1,1,2],[1,2,1],[2,1,1]]解析相比于Permutations,...原创 2019-04-02 15:02:52 · 188 阅读 · 0 评论 -
[LeetCode] 51. N-Queens
N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle...原创 2019-04-02 16:15:46 · 185 阅读 · 0 评论 -
[LeetCode] 93. Restore IP Addresses
Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: “25525511135”Output: [“255.255.11.135”, “255.255.111.3...原创 2019-07-25 20:28:53 · 115 阅读 · 0 评论 -
[LeetCode] 78. Subsets && 90. Subsets II
SubsetsGiven a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[[3],[...原创 2019-07-26 20:17:42 · 147 阅读 · 0 评论 -
[leetcode] 131. Palindrome Partitioning
Palindrome PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.Example:Input: “aab”Output:[[“a...原创 2019-08-16 16:48:42 · 162 阅读 · 0 评论