SOURCE

var maxProfit = function(prices) {
    // if (prices <= 1 || prices == null) {
    //     return 0;
    // }
    let maxP = 0;
    for (let i = 0; i < prices.length; i++) {
        if (prices[i] > prices[i-1]) {
            maxP += prices[i] - prices[i-1];
        }
    }
    return maxP;
};
console 命令行工具 X clear

                    
>
console