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 find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).

思路:这次可以多次买卖。那么将每一次涨价都累加。

31. leetcode 122. Best Time to Buy and Sell Stock II的更多相关文章

  1. [LeetCode] 122. Best Time to Buy and Sell Stock II 买卖股票的最佳时间 II

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  2. LeetCode 122. Best Time to Buy and Sell Stock II (stock problem)

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  3. LeetCode 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 al ...

  4. leetcode 122. Best Time to Buy and Sell Stock II ----- java

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  5. Java [Leetcode 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 ...

  6. LeetCode 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 ...

  7. [leetcode]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 al ...

  8. Java for LeetCode 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 al ...

  9. LeetCode 122 Best Time to Buy and Sell Stock II(股票买入卖出的最佳时间 II)

    翻译 话说你有一个数组,当中第i个元素表示第i天的股票价格. 设计一个算法以找到最大利润. 你能够尽可能多的进行交易(比如.多次买入卖出股票). 然而,你不能在同一时间来多次交易. (比如.你必须在下 ...

随机推荐

  1. RabbitMQ系列教程之四:路由(Routing)

    (使用Net客户端)在上一个教程中,我们构建了一个简单的日志系统,我们能够向许多消息接受者广播发送日志消息.在本教程中,我们将为其添加一项功能 ,这个功能是我们将只订阅消息的一个子集成为可能. 例如, ...

  2. Example010实现浏览器兼容改内容的函数,自写

    <!-- 实例010实现浏览器兼容改内容的函数 --> <!DOCTYPE html> <html lang="en"> <head> ...

  3. android怎么输出信息到logcat

  4. Vim按Esc后光标左移问题的解决

    参考了这篇文章http://vim.wikia.com/wiki/Prevent_escape_from_moving_the_cursor_one_character_to_the_left 在Vi ...

  5. C#设置WebBrowser默认浏览器

    由于VS的WebBrowser控件的默认浏览器是IE7,好多网页兼容性不是很好,所以要修改下默认浏览器. 设置前: 设置后:    在WebBrowser界面加载时执行以下方法,设置浏览器. /// ...

  6. MySQL(二)--事务与视图

    一.事务 1.提交 2.回滚 3.ACID特性 二.视图 1.创建视图 2.删除视图 3.更新视图 4.使用视图 三.子查询 1. 使用子查询 2. 标量子查询 3. 关联子查询 一.事务 在 RDB ...

  7. 我的学习之路_第二十五_javaScript

    Javascript 作用:可以对表单数据进行校验,可以对页面实现一些动态效果 定义: JavaScript一种直译式脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型. 它的解释器被称为 ...

  8. tcp/ip通信传输流

    利用TCP/IP协议族进行网络通信时,会通过分层顺序与对方进行通信,发送端从应用层往下走,接收端则往应用层方向走. 我们用HTTP进行举例 客户端在应用层发出想要看到某个web页面的http请求.HT ...

  9. 为实体类增加toJSON方法

    后期子类继承该基础类即可. package com.lichmama.test; import java.io.Serializable; import java.lang.reflect.Field ...

  10. 关于Android log拿不到的情况

    遇到很多开发者说crash了,log没有看到..出现类似情况的基本原因是因为现在的国产厂商如crash了会直接将进程杀掉,于是你的studio就看不到了,可以往下面几个方向去想办法找到crash的lo ...