leetcode 122 best stock 2
class Solution:
def maxProfit(self, prices: List[int]) -> int:
size = len(prices)
ans = 0
for i in range(1, size):
# This only calculates the accumulation profit in the case of existence of profits
#
ans += max(0, prices[i]-prices[i-1])
return ans
1234567891011