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

时间:2020-06-18 19:04:08   收藏:0   阅读:55

技术分享图片

class Solution {
    public int maxProfit(int[] prices) {
        int profit=0;
        for(int i=1;i<prices.length;i++){
            int tmp=prices[i]-prices[i-1];
            if(tmp>0) profit+=tmp;
        }
        return profit;
    }
}

技术分享图片

 

原文:https://www.cnblogs.com/doyi111/p/13159023.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!