bumpsoo 2025-05-09 15:23:03 +00:00
parent b4561ecb99
commit de7b15c917

View file

@ -0,0 +1,13 @@
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii
from typing import List
class Solution:
def maxProfit(self, prices: List[int]) -> int:
result = 0
last = prices[0]
for i in range(1, len(prices)):
if last < prices[i]:
result += prices[i] - last
last = prices[i]
return result