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:
11
121-best-time-to-buy-and-sell-stock/soln.py
Normal file
11
121-best-time-to-buy-and-sell-stock/soln.py
Normal file
@@ -0,0 +1,11 @@
|
||||
def maxProfit(self, prices: list[int]) -> int:
|
||||
lowest = prices[0]
|
||||
max_profit = 0
|
||||
|
||||
for x in prices[1:]:
|
||||
if x - lowest > max_profit:
|
||||
max_profit = x - lowest
|
||||
if x < lowest:
|
||||
lowest = x
|
||||
|
||||
return max_profit
|
||||
Reference in New Issue
Block a user