BiruLyu
7/29/2017 - 9:29 PM

122. Best Time to Buy and Sell Stock II.java

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

        return total;
    }
}