class Solution {
public int maxProfit(int[] prices) {
int max = 0;
for(int i=1;i<prices.length;i++){
if(prices[i]>prices[i-1]){
max = max + prices[i] - prices[i-1];
}
}
return max;
}
}
122. Best Time to Buy and Sell Stock II
最新推荐文章于 2025-04-24 16:18:21 发布