![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Backtracking
文章平均质量分 74
zshouyi
这个作者很懒,什么都没留下…
展开
-
216. Combination Sum III
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1:Inpu原创 2017-03-01 08:05:17 · 185 阅读 · 0 评论 -
22. Generate Parentheses
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:[ "((()))", "(()())", "(())()", "()(())原创 2017-04-20 11:40:21 · 322 阅读 · 0 评论 -
351. Android Unlock Patterns
Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock screen, which consist of minimum of m keys and maxim原创 2017-05-12 10:25:12 · 319 阅读 · 0 评论 -
89. Gray Code
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原创 2017-05-14 03:16:11 · 371 阅读 · 0 评论 -
77. Combinations
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],]原创 2017-05-14 03:44:11 · 270 阅读 · 0 评论 -
211. Add and Search Word - Data structure design
Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only lett原创 2017-05-14 07:44:04 · 335 阅读 · 0 评论 -
401. Binary Watch
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant bit o原创 2017-05-14 09:38:01 · 276 阅读 · 0 评论 -
254. Factor Combinations
Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4.Write a function that takes an integer n and return all possible combinations of its factors. Note:原创 2017-05-14 13:38:23 · 282 阅读 · 0 评论 -
267. Palindrome Permutation II
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.For example:Given s = "aabb", return ["原创 2017-05-14 16:01:06 · 276 阅读 · 0 评论 -
526. Beautiful Arrangement
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 ≤ i原创 2017-05-15 02:48:06 · 322 阅读 · 0 评论 -
544. Output Contest Matches
During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good strategy to make the conte原创 2017-05-06 09:54:16 · 497 阅读 · 0 评论 -
93. Restore IP Addresses
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"]. (Orde原创 2017-04-26 05:44:04 · 350 阅读 · 0 评论 -
294. Flip Game II
You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". Th原创 2017-04-28 07:51:27 · 638 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number
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原创 2017-04-11 05:34:20 · 670 阅读 · 0 评论 -
39. Combination Sum
Given a set of candidate numbers (C) (without duplicates) 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原创 2017-01-24 03:55:11 · 247 阅读 · 0 评论 -
40. 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原创 2017-01-24 04:35:28 · 309 阅读 · 0 评论 -
78. Subsets
Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1],原创 2017-01-24 04:55:50 · 291 阅读 · 0 评论 -
320. Generalized Abbreviation
Write a function to generate the generalized abbreviations of a word.Example:Given word = "word", return the following list (order does not matter):["word", "1ord", "w1rd", "wo1d", "wor1原创 2017-01-24 15:01:58 · 367 阅读 · 0 评论 -
90. Subsets II
Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,2], a s原创 2017-01-25 03:29:13 · 245 阅读 · 0 评论 -
46. Permutations
Given a collection of distinct 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], [3,2,1原创 2017-01-25 12:02:08 · 185 阅读 · 0 评论 -
47. Permutations II
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], [2,1原创 2017-01-25 12:03:46 · 304 阅读 · 0 评论 -
131. Palindrome Partitioning
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","b"],原创 2017-01-25 13:22:15 · 185 阅读 · 0 评论 -
79. Word Search
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原创 2017-02-25 09:28:36 · 254 阅读 · 0 评论 -
60. Permutation Sequence
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原创 2017-03-23 02:10:15 · 214 阅读 · 0 评论 -
357. Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x [11,22,33,44,原创 2017-03-23 07:20:04 · 289 阅读 · 0 评论 -
212. Word Search II
Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those hor原创 2017-06-23 01:58:09 · 302 阅读 · 0 评论