MySQL聚合函数常用的有五个SUMCOUNTAVGMIN/MAXAVG([DISTINCT]expr)返回expr的平均值。DISTINCT选项可用于返回expr的不同值的平均值。SELECTgender,AVG(age)FROMstudentGROUPBYgender;COUNT(expr)返回SELECT语句检索到的行中非NULL值的数目。SELECTCOUNT(*)FROMstudent;--返回检..
分类:
数据库 时间:
2014-12-30 01:50:00
阅读次数:
281
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-12-29 22:52:49
阅读次数:
198
Longest Substring with At Most Two Distinct CharactersGiven a string, find the length of the longest substring T that contains at most 2 distinct char...
分类:
其他好文 时间:
2014-12-28 16:53:21
阅读次数:
198
找到最多含有两个不同字符的子串的最长长度。例如:eoeabc,最长的是eoe为3,其他都为2.思路:用p1,p2表示两种字符串的最后一个出现的下标位置。初始p1为0. p2为-1.start初始化为0,表示两种字符串的开头。只要遍历一次string就可以得到结果了。首先我们要确定p2的值,那么i要一...
分类:
其他好文 时间:
2014-12-25 21:47:44
阅读次数:
150
今天跟大家分享一下mongodb中比较好玩的知识,主要包括:聚合,游标。一: 聚合 常见的聚合操作跟sql server一样,有:count,distinct,group,mapReduce。 count count是最简单,最容易,也是最常用的聚合工具,它的使用跟我们C#里面的count...
分类:
数据库 时间:
2014-12-25 20:04:48
阅读次数:
163
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1-...
分类:
其他好文 时间:
2014-12-24 21:32:51
阅读次数:
214
1 SELECT * from new; 2 SELECT stuname FROM new; //查询某一列 3 SELECT DISTINCT stuname FROM new; ...
分类:
数据库 时间:
2014-12-24 17:35:53
阅读次数:
137
1、查询去重数据select *, count(distinct name) from table group by name2.避免重复数据如果是用主键primary或者唯一索引unique区分了记录的唯一性,避免重复插入记录可以使用:insertignoreinto table_name(ema...
分类:
数据库 时间:
2014-12-24 13:23:50
阅读次数:
156
Given n distinct positive integers, integer k (k i) d[i][j][v] += d[i][j-1][v];22 if (v>=A[j-1]) d[i][j][v] += d[i-1][j-1][v-A[j-1...
分类:
其他好文 时间:
2014-12-24 13:22:01
阅读次数:
206
Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig...
分类:
其他好文 时间:
2014-12-24 11:36:21
阅读次数:
173