我就是一只勤劳的小蜜蜂啊O(∩_∩)O哈哈~
木有测试用例很容易理解错误题意滴。。。
public class Solution {
public int maxProfit(int[] prices) {
int profit = 0;
int pre = 0;
for(int i = 1; i < prices.length; i++){
if(prices[i] > prices[pre]){
profit += prices[i] - prices[pre];
}
pre = i;
}
return profit;
}
}