122. Best Time to Buy and Sell Stock II

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

你可能感兴趣的:(122. Best Time to Buy and Sell Stock II)