def maxProfit(prices):
"""
:type prices: List[int]
:rtype: int
"""
profit = 0
i = 0
while i < len(prices) - 1:
if prices[i+1] > prices[i]:
profit += prices[i+1] - prices[i]
i = i+1
return profit
//下次买的时候必须 先卖出 1 3 5 7 9 (9-1) = (3-1)+(5-3)+ (7-5)+ (9 - 7)相邻两个做差的 和 为正数的最大 利润。
// 1 5 3 6 7 的最大利润为 8 即为(5-1) + (6-3)+(7-6)= 8
//最大利润就是被拆分成两个差是正数 的累加和