这道题采用动态规划,可是我一开始没有想到。后来参考了discuss中前辈的代码和思路,才想通的。
方法二是因为每一步只和上一步的内容相关,所以可以只用O(n)的空间复杂度。下面是AC代码: 1 /** 2 * Solution DP 3 * we keep
a m*n matri...
分类:
其他好文 时间:
2014-05-10 08:43:12
阅读次数:
319
select Category from(select distinct Category from
T_Detail where CREATED_BY= @CREATED_BY AND RecordDate>=@RecordDate1 AND
RecordDate<@RecordDate2)t g...
分类:
数据库 时间:
2014-05-09 19:18:43
阅读次数:
339
在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供
有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的所有值。其原因是
distinct只能返回它的目标字段,而无法返回其它字段,这个问题让我困扰了很久....
分类:
数据库 时间:
2014-05-09 05:35:49
阅读次数:
465
? 组函数:– 类型和语法– 使用AVG、SUM、MIN、MAX、COUNT–
在组函数中使用DISTINCT关键字–
组函数中的NULL值何谓组函数组函数会对行集进行计算,为每个组提供一个结果。与单行函数不同,组函数用于对行集进行计算,从而为每个组提供一个结果。这些集合可以包含整个表,也可以包含表...
分类:
数据库 时间:
2014-05-09 03:37:18
阅读次数:
422
这道题的做法,一定得掌握啊!!! elegant & beautiful &
concise下面是AC代码: 1 /** 2 * Given a set of distinct integers, S, return all
possible subsets. 3 * 这道...
分类:
其他好文 时间:
2014-05-08 22:44:57
阅读次数:
424
Subsets IGiven a set of distinct integers, S,
return all possible subsets.Note:Elements in a subset must be in non-descending
order.The solution set m...
分类:
其他好文 时间:
2014-05-07 11:13:33
阅读次数:
299
一、逻辑查询处理的各个阶段
(5)SELECT DISTINCT TOP()
(1)FROM JOIN ON
(2)WHERE
(3)GROUP BY
(4)HAVING
(6)ORDER BY
上边语句是一个普通格式的查询语句,基本包含了所有的查询条件和关键字。你可能会发现前边的序号并不是按顺序来的,被你说对了,这...
分类:
数据库 时间:
2014-05-07 08:26:11
阅读次数:
476
SQL SERVER命令总结
查询语句:
SELECT [ALL/DISTINCT][TOP]
[as 别名][, as 别名]…
FROM [as 别名]…
[WHERE 条件表达式…]
[GROUP BY [HAVING]]
[ORDER BY[ASC/DESC]]
应该注意:SELECT语句的顺序:
SELECT-->FROM-->WHERE-->GROUP B...
分类:
数据库 时间:
2014-05-07 04:32:52
阅读次数:
561
最近在学scala语言,scala代码如下:
import scala.collection.JavaConversions._
object Solution {
def solution(A: Array[Int]): Int = {
// write your code in Scala 2.10
// using quick sort to so...
分类:
其他好文 时间:
2014-05-04 09:22:37
阅读次数:
341
题目:
Given 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 string which is formed from the original string by deleting some (c...
分类:
其他好文 时间:
2014-05-03 21:48:19
阅读次数:
252