122. Best Time to Buy and Sell Stock II

来源:互联网 发布:游光网络拉勾网 编辑:程序博客网 时间:2024/06/04 20:38
class Solution {public:    int maxProfit(vector<int>& prices) {    int ret=0;        for(int i=1;i<prices.size();i++)        {            ret+=max(0,prices[i]-prices[i-1]);        }        return ret;    }};
0 0
原创粉丝点击