LeetCode 122. 买卖股票的最佳时机 II

class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int res=0;
        for(int i=0;i<prices.size()-1;i++)
            res+=max(0,prices[i+1]-prices[i]);
        return res;
    }
};
posted @ 2023-05-09 15:54  穿过雾的阴霾  阅读(15)  评论(0)    收藏  举报