[LintCode] Best Time to Buy and Sell Stock II 买股票的最佳时间之二

Posted Grandyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LintCode] 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).

Example

Given an example [2,1,2,0,1], return 2

 

s

 

以上是关于[LintCode] Best Time to Buy and Sell Stock II 买股票的最佳时间之二的主要内容,如果未能解决你的问题,请参考以下文章

[LintCode] Best Time to Buy and Sell Stock II 买股票的最佳时间之二

算法分析与设计第一周121.Best Time to Buy and Sell Stock&122. Best Time to Buy and Sell Stock II

Best Time to Buy and Sell Stock & Best Time to Buy and Sell Stock II

最强解析面试题:best-time-to-buy-and-sell-stock

最强解析面试题:best-time-to-buy-and-sell-stock

121. Best Time to Buy and Sell Stock