/* 找一次操作能获取最大利润的一次交易(即题目121)的idxBuy和idxSell,这次交易称为首次交易 然后分5中情况: 情况1:最优解就只有“首次交易” 情况2:“首次交易”加上左边的交易得到最优解 情况3:“首次交易”加上右边的交易得到最优解 情况4:“首次交易”不做,两边的交易得到最优解... ...
分类:
其他好文 时间:
2017-11-03 18:53:04
阅读次数:
118
122. Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to ...
分类:
编程语言 时间:
2017-10-29 20:18:35
阅读次数:
184
// Best Time to Buy and Sell Stock 1class Solution { public: int maxProfit(vector& prices) { if(prices.size()==0) return 0; int maxres=prices[prices.s... ...
分类:
其他好文 时间:
2017-10-29 17:31:51
阅读次数:
142
程序清单10.1+10.2+10.3 stock.cpp main.cpp 修改stock.cpp文件中的show方法,使其数字格式统一 小结 构造函数和析构函数 程序清单10.4+10.5+10.6 头文件 函数定义 主函数 最后两行输出是析构函数调用的结果。 栈先进后出 辨析三个const 如声 ...
分类:
编程语言 时间:
2017-10-28 12:37:37
阅读次数:
193
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction ...
分类:
其他好文 时间:
2017-10-24 01:25:37
阅读次数:
180
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/ 题目大意:基本定义与121类似,不同点:121买卖股票只能有一次,且在这所有的一次买卖中找出最大利润值;122买卖股票不限次数,要求在 ...
分类:
其他好文 时间:
2017-10-22 21:04:10
阅读次数:
140
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/ 题目大意:给出一串数组,找到差值最大的差值是多少,要求只能用下标大的减下标小的,例子如下图: 法一(超时):直接两个for循环,进行一一比较 ...
分类:
其他好文 时间:
2017-10-20 21:34:36
阅读次数:
173
Regression-Case Study (Regression可以做很多事情,例如Stock Market Forecast、Self-driving Car、Recommendation等等 ,在这里是通过预测宝可梦(pokemons)进化后过的CP值(战斗力),来说明Regression) ...
分类:
其他好文 时间:
2017-10-20 16:51:50
阅读次数:
352
Description 尽管奶牛们天生谨慎,她们仍然在住房抵押信贷市场中受到打击,现在她们开始着手于股市。 Bessie很有先见之明,她不仅知道今天S (2 <= S <= 50)只股票的价格,还知道接下来一共D(2 <= D <= 10)天的(包括今天)。 给定一个D天的股票价格矩阵(1 <= 价 ...
分类:
其他好文 时间:
2017-10-20 10:15:09
阅读次数:
203