Backtracking
文章平均质量分 68
NoooName
这个作者很懒,什么都没留下…
展开
-
[Leetcode]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],]原创 2015-01-29 22:42:26 · 284 阅读 · 0 评论 -
[Leetcode]Subsets II
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-21 13:29:46 · 467 阅读 · 0 评论 -
[Leetcode]Subsets
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-20 16:52:32 · 361 阅读 · 0 评论 -
[Leetcode]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","原创 2015-02-01 23:24:29 · 294 阅读 · 0 评论 -
[Leetcode]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原创 2015-02-01 15:16:41 · 304 阅读 · 0 评论 -
[Leetcode]Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3原创 2015-02-02 14:37:19 · 289 阅读 · 0 评论 -
[Leetcode]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原创 2015-02-02 13:38:02 · 336 阅读 · 0 评论 -
[Leetcode]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原创 2015-02-01 22:27:50 · 375 阅读 · 0 评论 -
[Leetcode]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-30 23:32:02 · 349 阅读 · 0 评论 -
[Leetcode]Combination Sum
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-31 17:06:39 · 294 阅读 · 0 评论 -
[Leetcode]N-Queens II
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.N-Queens的扩展题,这题不要求输出结果集,只要求输出结果的个数~解法完全是一样的,其实更简单了,直接输出结果数量就行~原创 2015-01-30 23:39:27 · 280 阅读 · 0 评论 -
[Leetcode]Permutations
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-30 19:39:15 · 302 阅读 · 0 评论 -
[Leetcode]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:"((()))", "(()())", "(())()", "()(())", "()()原创 2015-01-31 14:26:21 · 269 阅读 · 0 评论 -
[Leetcode]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-31 23:59:14 · 302 阅读 · 0 评论 -
[Leetcode]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], and [2,1原创 2015-01-30 20:19:34 · 280 阅读 · 0 评论 -
[Leetcode]Sudoku Solver
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-03-26 05:01:12 · 430 阅读 · 0 评论