原题地址最直观的想法就是划分成两个子问题,每个子问题变成了:求在某个范围内交易一次的最大利润在只能交易一次的情况下,如何求一段时间内的最大利润?其实就是找股价最低的一天买进,然后在股价最高的一天卖出,当然,卖股票要在买股票之后。用迭代法求这个问题非常容易,令profits[i]表示截至到第i天的最大...
分类:
其他好文 时间:
2015-01-21 15:01:30
阅读次数:
165
思路:将两段最大的利润相加,一段的最大利润不一定只在一个上升期内,例如在绿线间就有两个上升区间 只要算出i之前的最大利润和i之后的最大利润相加就行,因为i不可能同时是峰值或者谷值,所以能保证不是在同一天买进和卖出 绿线的利润加上红线利润是最大利润。 class Solution { // 算出利润最...
分类:
其他好文 时间:
2015-01-20 23:46:30
阅读次数:
228
1. Addition to existing stock is NOT allowed to implement FIFO concept . Because FIFO is carried out based on the goods receipt date , if there is an ...
分类:
其他好文 时间:
2015-01-20 19:56:58
阅读次数:
210
将Ext JS 5应用程序导入Web项目中
相关资料:
http://docs.sencha.com/extjs/5.1/getting_started/welcome_to_extjs.html
效果图:
工程目录结构图:
准备资料:
先到官网上下载ext-5.1.0-gpl.zip然后解压,官网上的我看到buy我就没敢下载了,嘻嘻也可以到csdn上...
分类:
Web程序 时间:
2015-01-20 12:03:14
阅读次数:
199
遍历价格vector,把每段上升期间的利润加起来,注意最后结束时记得再计算最后一次的利润 class Solution { // 把每段上升期间的利润加起来 // minVal: 低谷值 // maxVal: 峰值 // profit: 利润
public: int maxProfit(vector...
分类:
其他好文 时间:
2015-01-19 00:01:46
阅读次数:
294
Problem Description
You travel a lot by bus and the costs of all the seperate tickets are starting to add up.
Therefore you want to see if it might be advantageous for you to buy a bus pass.
...
分类:
其他好文 时间:
2015-01-18 11:56:00
阅读次数:
246
Stock ExchangeTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 4578Accepted: 1618DescriptionThe world financial crisis is quite a subject. Som...
分类:
其他好文 时间:
2015-01-17 12:34:44
阅读次数:
230
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
分类:
其他好文 时间:
2015-01-15 12:38:33
阅读次数:
158
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:
其他好文 时间:
2015-01-15 12:34:54
阅读次数:
111
Preface:前段时间boss突发奇想,想要检测iPhone6供货,吓我,这是干啥呢。同仁提到肯定是想抢iPhone6,打开官网:http://store.apple.com/cn/buy-iphone/iphone6,在当时的时候显示缺货,原来是想要检测官网iPhone6的页面变化,等到缺货变为有现货的时候立马下单抢,跟抢火车票似的,隔一段时间访问一次,检测页面是否发生了变化,发生了变化手机短...
分类:
编程语言 时间:
2015-01-15 10:59:03
阅读次数:
191