首页 > 其他 > 详细

Lintcode 150.买卖股票的最佳时机 II

时间:2017-01-01 22:35:56      阅读:210      评论:0      收藏:0      [点我收藏+]

技术分享

------------------------------------------------------------

 

卧槽竟然连题意都没看懂,百度了才明白题目在说啥....我好方啊....o(╯□╰)o

 

AC代码:

class Solution {
    /**
     * @param prices: Given an integer array
     * @return: Maximum profit
     */
    public int maxProfit(int[] prices) {
        int res=0;
        for(int i=1;i<prices.length;i++){
            int t=prices[i]-prices[i-1];
            if(t>0) res+=t;
        }
        return res;
    }
};

 

 

题目来源: http://www.lintcode.com/zh-cn/problem/best-time-to-buy-and-sell-stock-ii/#

Lintcode 150.买卖股票的最佳时机 II

原文:http://www.cnblogs.com/cc11001100/p/6241654.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!