Mon, 16 Dec 2019 11:53:30 +0000
  • A (Algotithm) 至少做一个leetcode的算法题
  • R (Review) 阅读并点评一篇英文的技术文章
  • T (Tip) 学习一个技术技巧
  • S (Share) 分享一篇有观点和思考的技术文章

每周一次,坚持一年

Algorithm

Description Best Time to Buy and Sell Stock II

Solution

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

Review

Tip

Share



blog comments powered by Disqus