[Algorithm] 39 week(10.24 ~ 10.30) 2/3

Dev_min·2022년 10월 25일
0

algorithm

목록 보기
127/157

122. Best Time to Buy and Sell Stock II

var maxProfit = function(prices) {
    let result = 0;

    for(let i = 0; i < prices.length - 1; i++){
        if(prices[i+1] > prices[i]){
            result += prices[i+1] - prices[i];
        }
    }

    return result;
};
profile
TIL record

0개의 댓글