码迷,mamicode.com
首页 >  
搜索关键字:回溯    ( 2360个结果
leetcode || 77、Combinations
problem: 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],...
分类:其他好文   时间:2015-04-10 09:32:46    阅读次数:148
LeetCode --- 93. Restore IP Addresses
题目链接: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", "25...
分类:其他好文   时间:2015-04-09 11:57:09    阅读次数:191
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-04-08 15:06:58    阅读次数:79
枚举:给全排列限定条件
枚举:给全排列限定条件枚举:给全排列限定条件假如我们要求 abc + def = ghi abcdefghi 均为数字,且各不相同,求符合条件的式子可以用9个for…通过递归回溯来 枚举 然后在结束的时候判断一下…// CreateTime: 2015-04-07 23:26:57#include ...
分类:其他好文   时间:2015-04-08 00:59:35    阅读次数:145
枚举:全排列
枚举:全排列枚举:全排列递归回溯实现的全排列:// CreateTime: 2015-04-07 23:26:57#include using namespace std;int a[10];int v[10];void dfs(int n) { if (n == 10) { for (int i ...
分类:其他好文   时间:2015-04-08 00:52:37    阅读次数:249
hdu4739(回溯)
题意: 给出宝藏个数,然后给出每个宝藏的位置; 如果四个宝藏构成正方形就能取走; 问最多取走几个; #include #include #include using namespace std; const int N = 25; int n, ans; int cnt[105][105]; struct node { int x; int y; bool operator<(no...
分类:其他好文   时间:2015-04-07 23:34:29    阅读次数:384
LeetCode --- 89. Gray Code
题目链接: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 th...
分类:其他好文   时间:2015-04-07 23:34:18    阅读次数:318
LeetCode --- 90. Subsets II
题目链接: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 ...
分类:其他好文   时间:2015-04-07 23:33:25    阅读次数:156
每日一题17:八皇后问题
八皇后问题是由国际西洋棋棋手马克斯·贝瑟尔于1848年提出的:在8X8格的国际象棋上摆放八个皇后,使其不能互相攻击,即任意两个皇后都不能处于同一行、同一列或同一斜线上,问有多少种摆法。 高斯认为有76种方案。1854年在柏林的象棋杂志上不同的作者发表了40种不同的解,后来有人用图论的方法解出92种结果。解题的思路如下:从棋盘的第一行起,先选择第一个格子作为第一个皇后的位置,然后在第二行中从第一个格子...
分类:其他好文   时间:2015-04-07 09:49:32    阅读次数:130
[LeetCode] Wildcard Matching 字符串匹配,kmp,回溯,dp
Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the e...
分类:其他好文   时间:2015-04-07 07:09:42    阅读次数:441
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!