mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-15 01:07:07 +00:00
Time: 3 ms (99.17%), Space: 17.4 MB (99.89%) - LeetHub
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user