Skip to content

Commit

Permalink
Create 0122-best-time-to-buy-and-sell-stock-ii.py
Browse files Browse the repository at this point in the history
  • Loading branch information
neetcode-gh authored Jun 6, 2023
1 parent f78ed9f commit 502ce28
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/0122-best-time-to-buy-and-sell-stock-ii.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Solution:
def maxProfit(self, prices: List[int]) -> int:
max_profit = 0
for i in range(1, len(prices)):
if prices[i] > prices[i-1]:
max_profit += prices[i] - prices[i-1]
return max_profit

0 comments on commit 502ce28

Please sign in to comment.