122. Best Time to Buy and Sell Stock II

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了122. Best Time to Buy and Sell Stock II相关的知识,希望对你有一定的参考价值。

 1 class Solution {
 2 public:
 3     int maxProfit(vector<int>& prices) {
 4         int profit = 0;
 5         for (size_t i = 1; i < prices.size(); ++i) {
 6             if (prices[i] - prices[i - 1] > 0) profit += prices[i] - prices[i - 1];
 7         }
 8         return profit;
 9     }
10 };

 

以上是关于122. Best Time to Buy and Sell Stock II的主要内容,如果未能解决你的问题,请参考以下文章

122. Best Time to Buy and Sell Stock II

LeetCode 122. Best Time to Buy and Sell Stock II

!!!!!122. Best Time to Buy and Sell Stock II

122. Best Time to Buy and Sell Stock II

122.Best Time to Buy and Sell Stock II

leetcode122-Best Time to Buy and Sell Stock II