题目链接题意: find the maximum positive difference
between the price on the ith day and the jth day附上代码: 1 class Solution { 2
public: 3 int maxProfit(ve...
分类:
其他好文 时间:
2014-05-28 03:49:45
阅读次数:
307
Best FinancingTime Limit: 20000/10000 MS
(Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s):
120Accepted Submission(s): 24Probl...
分类:
其他好文 时间:
2014-05-27 17:52:10
阅读次数:
223
題目鏈接題意 : 將幾個片段如圖所示方法縮成一個序列,求出最短這個序列。思路 :
其實我也不知道怎麼做。。。。。看網上都用了DP。。。。。但是我不會。。。。。這個DP不錯,還有用KMP+状压DP做的 1 //1699 2 #include 3
#include 4 #include 5 #in...
分类:
其他好文 时间:
2014-05-27 16:06:19
阅读次数:
282
刚打开游标的时候,是位于一个空行,要用fetch into
才能到第一行。只是要注意用更新游标的时候,不能在游标期间commit. 否则会报ORA-01002: fetch out of
sequence就是COMMIT导致的错误。在打开有for update的cursor时,系统会给取出的数据加上...
分类:
数据库 时间:
2014-05-26 01:07:05
阅读次数:
405
Best FinancingTime Limit: 20000/10000 MS
(Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s):
29Accepted Submission(s): 3Problem...
分类:
其他好文 时间:
2014-05-25 20:13:10
阅读次数:
211
Graphic SequenceA graphic sequence is a
sequence of numbers which can be thedegree sequenceof somegraph. A sequence can
be checked to determine if it ...
分类:
其他好文 时间:
2014-05-25 19:18:00
阅读次数:
331
【题目】
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space ...
分类:
其他好文 时间:
2014-05-25 07:39:05
阅读次数:
256
【题目】
The set [1,2,3,…,n] contains a total of n! unique permutations.
By listing and labeling all of the permutations in order,
We get the following sequence (ie, for n = 3):
"123"
"132"
"213"
"231"
"312"
"321"
Given n and k, return the kth permutation ...
分类:
其他好文 时间:
2014-05-25 06:13:37
阅读次数:
276
题目:这个题目里要求最多交易2次。也就是说可以只交易一次,不交易也可以。
分析:将整个交易序列分割成两部分,求出这样的一种分割,使得两部分连续子序列的和相加的结果最大,当然,如果不进行分割,就是求出整个序列的最大连续子序列的和。
那么分割点就可能是任意位置。找出取得最大值的分割点,返回最大值。
int maxProfit(vector &prices) {
const int le...
分类:
其他好文 时间:
2014-05-24 20:54:57
阅读次数:
402
问题:股票交易,交易的次数不限,但是要求在购买新的股票前,必须将旧的股票卖出,即同一时间,最多只能持有一只股票。要求在给定的交易价格序列中,计算出最大的收益。
分析:
保证利润最大,就要求在局部的价格波动中,能在低价买进,高价卖出,也就是说,找个价格走势的递增区间,并且这里可以交易多次,所以可以找到多个价格走势的递增区间,所有区间的收益的和就是最大的利润。
再看下不完全是递增区间的...
分类:
其他好文 时间:
2014-05-24 19:49:02
阅读次数:
349