Time: 3 ms (99.17%), Space: 17.4 MB (99.89%) - LeetHub

This commit is contained in:
Deven
2024-10-20 13:42:31 -04:00
parent 6a099c35a3
commit 987aaf1d29
@@ -0,0 +1,11 @@
class Solution:
def maxProfit(self, prices: List[int]) -> int:
profit = 0
for i in range(len(prices) - 1):
before = prices[i]
after = prices[i + 1]
if before < after:
profit += after - before
return profit