mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
12 lines
300 B
Python
12 lines
300 B
Python
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
|