122. Best Time to Buy and Sell Stock II

我恨这个题,这甚至不是真的dp吧,不知道在考什么

class Solution {
    public int maxProfit(int[] prices) {
        int maxP = 0;
        for (int i = 1; i < prices.length; i++) {
            maxP += Math.max(0, prices[i] - prices[i-1]);
        }
        return maxP;
    }
}

Last updated