public class Solution {
public int maxProfit(int[] prices) {
int profit = 0;
for(int i=0; i<prices.length-1; i++){
if (prices[i]<prices[i+1]){
profit += prices[i+1] - prices[i];
}
}
return profit;
}
}
Best Time to Buy and Sell Stock II
最新推荐文章于 2022-11-16 09:46:40 发布