题目链接:http://poj.org/problem?id=3061先说说最朴素的算法,那就是for嵌套了,复杂度是O(n^3)太慢,想都不用想一定会超时。接下来有的人可能会想到二分搜索的思想,将时间复杂度优化成O(n*logn),我试了一下,可以AC。但是这都不是今天要说的重点,今天要说的是一个...
分类:
其他好文 时间:
2014-08-29 14:21:27
阅读次数:
228
SubsetsGiven 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...
分类:
其他好文 时间:
2014-08-28 17:58:05
阅读次数:
356
思想:动态规划。 D[i][j] = D[i][j-1] + (T[i-1] == S[j-1] ? D[i-1][j-1] : 0);
改进后:空间复杂度 O(T.size()).
分类:
其他好文 时间:
2014-08-27 16:13:07
阅读次数:
175
这两者本质上应该没有可比性,distinct 取出唯一列,group by 是分组,但有时候在优化的时候,在没有聚合函数的时候,他们查出来的结果也一样。举例来说可能方便一点。A表id numa 1b 2c 3a 4c 7d 3e 5如果只选出id列,用distinct和group by 一样的。se...
分类:
数据库 时间:
2014-08-27 12:39:17
阅读次数:
240
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.思路:穷举所有合法的摆法。 1 class Solut...
分类:
其他好文 时间:
2014-08-27 10:54:07
阅读次数:
206
LeetCode: Distinct SubsequencesGiven a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new...
分类:
其他好文 时间:
2014-08-26 22:53:36
阅读次数:
245
Description
a program that, given a natural number N between 0 and 4999 (inclusively), and M distinct decimal digits X1,X2..XM (at least one), finds the smallest strictly positive multiple of N that ...
分类:
其他好文 时间:
2014-08-26 21:34:06
阅读次数:
342
Sorting It All Out
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 27929
Accepted: 9655
Description
An ascending sorted sequence of distinct values is on...
分类:
其他好文 时间:
2014-08-26 19:40:46
阅读次数:
194
一、可以用subSequence方法截取任意长度的字符
二、判断字符串是否相等
三、判断字符串是否为空的四种方法:
最近做项目Android时遇到了字符串的截取,判断字符串是否相等和字符串是否为空问题刚好用的上自己也知道些,所以整理了方便以后用,和供大家参考,有什么更好的方法或者其它方法我么可以一起交流,谢谢大家!...
分类:
移动开发 时间:
2014-08-26 09:56:15
阅读次数:
308
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
Java Solutions( Refer to blog
http://blog.csdn.net/mbh_199...
分类:
其他好文 时间:
2014-08-25 19:22:11
阅读次数:
207