class Solution {
public:
int maxProfit(vector<int>& prices) {
int max=0;
int len = prices.size();
for(int i=1;i<len;i++){
if(prices[i]>prices[i-1]){
max += prices[i] - prices[i-1];
}
}
return max;
}
};
leetcode-122-best time to buy and sell stock II
最新推荐文章于 2020-02-21 14:35:45 发布