122. Best Time to Buy and Sell Stock II

问题描述

解决方案

class Solution {
public:
    int maxProfit(vector<int>& prices) { 
        int ret =0;
        for(int i=1;i<prices.size();++i){
            ret +=max(prices[i]-prices[i-1],0); 
        }
        return ret ; 
    }
};
posted @ 2016-08-24 22:57  弦断  阅读(193)  评论(0编辑  收藏  举报