码迷,mamicode.com
首页 >  
搜索关键字:backtracking    ( 114个结果
leetcode Ch3-DFS & Backtracking II
一、Gray Code 1 class Solution 2 { 3 public: 4 vector grayCode(int n) 5 { 6 vector result={0}; 7 if(n==0) return result; 8 ...
分类:其他好文   时间:2015-05-15 10:24:33    阅读次数:139
87. Scramble String Leetcode Python
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / gr ...
分类:编程语言   时间:2015-04-17 11:38:26    阅读次数:129
LeetCode39/40/79 Combination SumI/II /Word Search--backtracking**
一: LeetCode39 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 nu...
分类:其他好文   时间:2015-04-12 13:28:04    阅读次数:190
2015.04.01 Leetcode Generate Parentheses
LeetCode - 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: "((()))", "(()())", "(())()", "()(())", "()()()" 题解: 需要用dfs -backtracking. 给定的n为括号对,也就是有n个...
分类:其他好文   时间:2015-04-02 13:30:32    阅读次数:158
[LeetCode] Palindrome Partitioning
(Version 0.0)这题的思路比较straightforward,可以看出会有overlapping的子问题,因此可以先按DP做法用一个二维数组存储对于某一substring是不是palindrome的判断,然后做backtracking时可以利用这个DP二维数组的结果来跳过重复的palind...
分类:其他好文   时间:2015-03-12 11:07:43    阅读次数:158
52.N-Queens II (n皇后问题,返回可能数,回溯,递归实现)
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number ofdistinct solutions. HideTags  Backtracking #pragma once #include using namespace s...
分类:其他好文   时间:2015-01-31 12:50:03    阅读次数:148
[C++]LeetCode: 121 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 [ ...
分类:编程语言   时间:2015-01-25 16:41:55    阅读次数:201
[C++]LeetCode: 120 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 [...
分类:编程语言   时间:2015-01-25 13:57:13    阅读次数:206
[C++]LeetCode: 113 Word Break II (DP && Backtacking) 求解拆分组合
题目: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given...
分类:编程语言   时间:2015-01-20 22:22:42    阅读次数:241
[C++]LeetCode: 114 Permutation Sequence(返回第k个阶乘序列——寻找数学规律)
题目: 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"...
分类:编程语言   时间:2015-01-20 22:19:05    阅读次数:209
114条   上一页 1 ... 7 8 9 10 11 12 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!