fun maxProfit(prices: IntArray): Int {
var profits = 0 //利润
for(i in 0 until prices.size-1){
if(prices[i]<prices[i+1]){ //下一天的值大于今天的值,其中差值既为利润
profits=prices[i+1]-prices[i]+profits
}
}
return profits
}
122. Best Time to Buy and Sell Stock II (Easy) fun maxProfit(prices: IntArray): Int { var profits = 0 //利润 for(i in 0 until prices.size-1){ if(prices[i]<prices[i+1]){ //下一天的值大于今天的值,其中差值既为利润 profits=prices[i