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 783de6a commit eb177e6Copy full SHA for eb177e6
best-time-to-buy-and-sell-stock/printjin-gmailcom.py
@@ -0,0 +1,10 @@
1
+class Solution:
2
+ def maxProfit(self, price):
3
+ min_price = float('inf')
4
+ max_profit = 0
5
+ for price in prices:
6
+ if price < min_price:
7
+ min_price = price
8
+ elif price - min_price > max_profit:
9
+ max_profit = price - min_price
10
+ return max_profit
0 commit comments