Skip to content

Commit 502ce28

Browse files
authored
Create 0122-best-time-to-buy-and-sell-stock-ii.py
1 parent f78ed9f commit 502ce28

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution:
2+
def maxProfit(self, prices: List[int]) -> int:
3+
max_profit = 0
4+
for i in range(1, len(prices)):
5+
if prices[i] > prices[i-1]:
6+
max_profit += prices[i] - prices[i-1]
7+
return max_profit

0 commit comments

Comments
 (0)