We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e33db1c commit 7cb90ccCopy full SHA for 7cb90cc
best-time-to-buy-and-sell-stock/changhyumm.py
@@ -0,0 +1,9 @@
1
+class Solution:
2
+ def maxProfit(self, prices: List[int]) -> int:
3
+ min_price = prices[0]
4
+ max_profit = 0
5
+ for i in range(0, len(prices) - 1):
6
+ min_price = min(prices[i], min_price)
7
+ profit = prices[i+1] - min_price
8
+ max_profit = max(profit, max_profit)
9
+ return max_profit
0 commit comments