【题目】
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
【题意】
解N皇后问题,N-Queens要求返回所有的解,而本题只需要返回可行解的数目
【思路】
DFS,参考N-Queens...
分类:
其他好文 时间:
2014-05-25 01:51:55
阅读次数:
236
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the f...
分类:
其他好文 时间:
2014-05-24 21:52:34
阅读次数:
320
题目:给定三个串str1,str2,str3,判断str3是否是str1,str2的交叉字符串。
交叉字符串:两个字符串的字符交叉,组成新的字符串,要求属于原来字符串中的字符在新的生成的交叉字符串中的顺序与原顺序相同。即若a、b在源字符串中时a在前面,那么在新的字串中时,a也的在b的前面。
回想问题Distinct
Subsequences,其形式表示为 S --通过合理的规则----得到...
分类:
其他好文 时间:
2014-05-24 18:14:24
阅读次数:
284
题目描述If the difference between any two adjancent
elements in a sequence is not more than K, then we call this sequence is a
K-diff sequence. A subseque...
分类:
其他好文 时间:
2014-05-24 09:39:27
阅读次数:
340
最近项目中在用Linq
Distinct想要将重复的资料去除时,发现它跟Any之类的方法有点不太一样,不能很直觉的在呼叫时直接带入重复数据判断的处理逻辑,所以当我们要用某个成员属性做重复数据的判断时,就必需绕一下路,这边稍微将处理的方法做个整理并记录一下。
首先为了方便接下去说明,我们必须先来准备后...
分类:
其他好文 时间:
2014-05-24 09:24:04
阅读次数:
263
MSS(Array[],N)//Where N is the number of
elements in array{sum=0; //current summax-sum=0;//Maximum Sumseq-start=0;//start
of the subsequenceseq-end=0;...
分类:
其他好文 时间:
2014-05-23 11:03:58
阅读次数:
221
问题:给定两个字符串S,T,对于S,可以删除其中的任意多个(包括0)字符,使其得到T。问有多少种删法可以得到T。
举例分析:
S:ababa
T: aba
dp[i][j] : 表示 S 从0 ~ i - 1,T从0~j - 1,所得到的方法数。i,j 表示长度。
初始条件:dp[i][0] = 1,T为空串,而空串总是任意串的字串。即,将S串的所有字符都删掉,就得到T。
状态转移...
分类:
其他好文 时间:
2014-05-23 00:54:13
阅读次数:
247
一个序列有N个数:A[1],A[2],A[3]……A[N],求最长非降子序列的长度。最重要的是要找出所谓的“状态”,本题目中是d[i],初始化最长长度为自己本身即一个单位长度。看是否要加入第i个元素,如果第i个元素a[i]比当前序列的最后一个元素a[j]大的话,那么加入,同时d[i]=d[j]+1;...
分类:
其他好文 时间:
2014-05-22 05:54:06
阅读次数:
228
问题描述
最长公共子序列,英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。
解决最长公共子序列,一种常用的办法,就是穷举法,组合出所有的情况,但是这样对于长序列的情况来说,是非常不实际。。
假设现在有...
分类:
其他好文 时间:
2014-05-21 13:55:35
阅读次数:
260
Description
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a ...
分类:
其他好文 时间:
2014-05-21 10:58:39
阅读次数:
237