Problem description:
Solution:
def maxProfit(self, prices: List[int]) -> int:
#return sum(y-x for y,x in zip(prices[1:],prices[:-1]) if y-x>0)
if len(prices)<1:
return 0
buyPrice,res = prices[0],0
for price in prices:
if price>=buyPrice:
res+=price - buyPrice
buyPrice = price
else:
buyPrice = price
return res