###### [LeetCode] 122. Best Time to Buy and Sell Stock II

int maxProfit(vector<int>& prices) {
if (prices.size() < 2)
return 0;
int minPrice = prices[0], maxPro = 0;
for (int i = 1; i < prices.size(); i++) {
if (prices[i] > prices[i - 1]) {
maxPro += prices[i] - minPrice;
minPrice = prices[i];
}
else
minPrice = min(minPrice, prices[i]);
}
return maxPro;
}

#### Leetcode_122_Best Time to Buy and Sell Stock II

2015-01-26 18:28:17

#### leetcode_c++：Best Time to Buy and Sell Stock II（122）

2016-06-10 23:19:48

#### leetcode【121+122+123 best time to buy and sell stock】【python】

2016-09-12 21:04:35

#### 【LeetCode】【Python题解】Best Time to Buy and Sell Stock II

2014-07-24 10:11:44

#### 【LeetCode】 Best Time to Buy and Sell Stock I II III IV 解题报告

2015-04-06 11:10:34

#### Best Time to Buy and Sell Stock II -- LeetCode

2014-04-09 05:33:51

#### LeetCode -- Best Time to Buy and Sell Stock II （贪心策略，差分序列）

2014-05-27 15:44:01

#### Best Time to Buy and Sell Stock -- LeetCode

2014-04-09 05:33:32

#### 【LeetCode-面试算法经典-Java实现】【121-Best Time to Buy and Sell Stock（最佳买卖股票的时间）】

2015-08-14 06:16:32

#### LeetCode(122)Best Time to Buy and Sell Stock2

2014-01-21 03:11:34

## 不良信息举报

[LeetCode] 122. Best Time to Buy and Sell Stock II