解法一:意味着每天都需要买卖
# 尽可能赚多的钱 等价于每天都买卖
profit = 0
for i in range(1, len(prices)):
tmp = prices[i] - prices[i - 1]
if tmp > 0: profit += tmp
return profit
该作者写的很详细
参考链接
解法一:意味着每天都需要买卖
# 尽可能赚多的钱 等价于每天都买卖
profit = 0
for i in range(1, len(prices)):
tmp = prices[i] - prices[i - 1]
if tmp > 0: profit += tmp
return profit
该作者写的很详细
参考链接