比如[1,3,5,2,6,1,3]
profit=(3-1)+(5-3)+(6-2)+(3-1)=3-1+5-3+(6-2)+(3-1)=(5-1)+(6-2)+(3-1)
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
profit=0
for i in range(1,len(prices)):
if prices[i]>prices[i-1]:
profit+=prices[i]-prices[i-1]
return profit