![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Backtracking
文章平均质量分 76
豆腐脑是咸的
这个作者很懒,什么都没留下…
展开
-
Permutation Sequence (Java)
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""3原创 2015-01-08 16:25:40 · 415 阅读 · 0 评论 -
N-Queens
The 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.原创 2015-01-23 20:36:32 · 315 阅读 · 0 评论 -
Regular Expression Matching (Java)
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st原创 2015-02-07 11:21:57 · 406 阅读 · 0 评论 -
Letter Combinations of a Phone Number (Java)
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st原创 2015-01-19 16:09:57 · 356 阅读 · 0 评论 -
Palindrome Partitioning (Java)
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","原创 2015-01-19 16:41:52 · 363 阅读 · 0 评论 -
Gray Code (Java)
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of原创 2015-01-19 11:14:23 · 377 阅读 · 0 评论 -
Word Search (Java)
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically原创 2014-12-26 20:54:21 · 408 阅读 · 0 评论 -
Sudoku Solver (Java)
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku原创 2015-02-06 16:24:45 · 318 阅读 · 0 评论 -
Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina原创 2015-01-19 11:46:07 · 261 阅读 · 0 评论 -
Subsets II (Java)
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain dupli原创 2015-01-19 09:52:53 · 386 阅读 · 0 评论 -
Combination Sum (Java)
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb原创 2015-01-19 11:34:17 · 282 阅读 · 0 评论 -
Permutations (Java)
Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].由于元素不能重复,所以要用原创 2015-01-19 08:55:42 · 380 阅读 · 0 评论 -
Restore IP Addresses (Java)
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order原创 2015-01-19 15:05:12 · 387 阅读 · 0 评论 -
Subsets (Java)
Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For exa原创 2015-01-19 09:39:52 · 634 阅读 · 0 评论 -
Combinations (Java)
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]原创 2015-01-19 09:06:01 · 391 阅读 · 0 评论 -
Generate Parentheses (Java)
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()原创 2015-01-19 10:24:06 · 403 阅读 · 0 评论 -
Permutations II (Java)
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].原创 2015-01-29 12:15:18 · 394 阅读 · 0 评论 -
N-Queens II (Java)
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.八皇后问题:所有皇后所在行、列、斜线上不能有其他皇后出现。用回溯法做,枚举第一行皇后可以在的所有位置,根据所在原创 2015-01-23 19:23:05 · 264 阅读 · 0 评论