Permutation p is
an ordered set of integers p1,??p2,??...,??pn,
consisting of n distinct positive integers, each of them doesn't exceed n.
We'll denote the i-th element of permutation p as pi.
...
分类:
其他好文 时间:
2014-07-22 23:00:15
阅读次数:
312
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-05-02 16:39:15
阅读次数:
315
去重有两层含义,一:是记录完全一样;二:是符合一定条件的认为是重复。根据表的数量,去重可划分为:单表去重和多表关联去重。对于去重,一般最容易想到的是用distinct,而distinct只能对记录完全重复的记录保留一条。distinct使用的是二重循环的方式来去重的,如果数据量非常大的时候,会导致性...
分类:
数据库 时间:
2014-05-01 11:36:20
阅读次数:
422
Oracle单表去重去重有两层含义,一:是记录完全一样。二:是符合一定条件的认为是重复。根据表的数量,去重可划分为:单表去重和多表关联去重。对于去重,一般最容易想到的是用distinct,而distinct只能对记录完全重复的记录保留一条。distinct使用的是二重循环的方式来去重的,如果数据量非...
分类:
数据库 时间:
2014-05-01 11:13:53
阅读次数:
555
Problem 1:Given a set of distinct integers, S,
return all possible subsets.Note:Elements in a subset must be in non-descending
order.The solution set ...
分类:
其他好文 时间:
2014-05-01 09:43:43
阅读次数:
414
在程序设计竞赛中,我们时常会遇到序列求最值的问题。在讲今天的问题之前,先小小的说明一下,子序列与子串的问题。
子序列:在原序列中不一定连续; 子串:在原序列中必须连续。 接下来,就开始今天要讲的最长公共子序列LCS(Longest Common
Subsequence).对于LCS这一类的...
分类:
其他好文 时间:
2014-05-01 01:38:24
阅读次数:
287
Pat1063代码
题目描述:
Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the number of distinct common numbers shared by the two sets,
and Nt is the to...
分类:
其他好文 时间:
2014-04-29 13:44:20
阅读次数:
325
最长上升子序列:
有两种基本方法:两个时间复杂度分别为O(n^2)和O(nlogn)。
O(n^2)
容易的出动态规划的递推公式dp[i]=max(dp[j])+1 j=1,2...i-1,dp[i]是以元素i结尾的最长子序列个数。
在O(n^2)的最长上升子序列中可以通过记录每个元素前缀元素位置的方式来得到整个的最长上升子序列。
代码:int LISOn2(int a[],int to...
分类:
其他好文 时间:
2014-04-29 13:24:22
阅读次数:
314
复合索引最令人困惑的当属索引列的顺序,不仅依赖于使用该索引的查询,更需考虑排序和分组。前段时候我发了个帖子:where条件顺序和复合索引字段顺序。感兴趣的朋友不妨参与讨论。今天我提个自己的观点。在应用开发阶段,【选择性】是我们首要考虑因素,请看简图:当出现sql性能问题时,你可能需要注意以下几个:1. 随机IO2. 排序(order by)3. 分组(group by or distinct)这时...
分类:
其他好文 时间:
2014-04-27 21:24:06
阅读次数:
353