mirror of
https://github.com/20kaushik02/leetcode-gulag.git
synced 2026-01-25 07:34:05 +00:00
let's try this again shall we
problems 1->10 of LC150
This commit is contained in:
8
122-best-time-to-buy-and-sell-stock-ii/soln.py
Normal file
8
122-best-time-to-buy-and-sell-stock-ii/soln.py
Normal file
@@ -0,0 +1,8 @@
|
||||
def maxProfit(self, prices: list[int]) -> int:
|
||||
cur_start = 0
|
||||
diff_sum = 0
|
||||
for idx in range(1, len(prices)):
|
||||
if prices[idx] > prices[cur_start]:
|
||||
diff_sum += prices[idx] - prices[cur_start]
|
||||
cur_start = idx
|
||||
return diff_sum
|
||||
Reference in New Issue
Block a user