Problem Description: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/

Basic idea: from code below, it seems super easy. But intuitively, we may use one more variable "tmp_max_profit" to record every times we get the max profit.

 class Solution {
public:
int maxProfit(vector<int> &prices) {
// Note: The Solution object is instantiated only once and is reused by each test case.
int max_profit = ;
for(int i = ; i < prices.size(); i ++) {
if(i + >= prices.size())
break; if(prices[i + ] > prices[i])
max_profit += prices[i + ] - prices[i];
} return max_profit;
}
};

最新文章

  1. C/C++ Memory Layout
  2. 微信小程序购物商城系统开发系列-目录结构
  3. 文本深度表示模型Word2Vec
  4. 二、verilogHDL行为描述建模
  5. Redis操作的封装类
  6. BOOTCAMP版本适配机型表
  7. 20151216JqueryUI---dialog代码备份
  8. json对象的处理
  9. MFC窗口风格 WS_style/WS_EX_style(超详细)
  10. appendGrid的使用
  11. iOS中有关配置 Apache 服务器的详细步骤
  12. javascript 学习随笔3
  13. react学习01
  14. [LeetCode] 动态规划入门题目
  15. 【mongodb系统学习之十一】mongodb删除数据
  16. 071、如何定制calico网络的IP池(2019-04-16 周二)
  17. JS制作蔡徐坤打篮球小游戏(鸡你太美?)
  18. 为django项目配置celery的后台启动
  19. [转]https://www.jianshu.com/p/06443248f4d8
  20. SQL记录-资源正忙online或nowait

热门文章

  1. Lucky String
  2. System.MissingMethodException: 找不到方法:
  3. LINUX DIFF命令详解
  4. [JAVA设计模式]第一部分:接口、抽象类、设计原则
  5. 8.mybatis动态SQL模糊查询 (多参数查询,使用parameterType)
  6. python_way,day4 内置函数(callable,chr,随机验证码,ord),装饰器
  7. STORM_0004_windows下zookeeper的伪集群的搭建
  8. 问题: unrecognized selector sent to class 0x10affab20
  9. Intel微处理器学习笔记(五) 中断
  10. Scrum Meeting---Eight(2015-11-3)