class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
res=0
for i in range(1,len(prices)):
if prices[i]-prices[i-1]>0:
res+=prices[i]-prices[i-1]
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
res=0
for i in range(1,len(prices)):
if prices[i]-prices[i-1]>0:
res+=prices[i]-prices[i-1]
return res
距离一样,直接过去和跳着过去距离是一样的