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 8854d7e commit 7c25530Copy full SHA for 7c25530
best-time-to-buy-and-sell-stock/8804who.py
@@ -0,0 +1,12 @@
1
+class Solution:
2
+ def maxProfit(self, prices: List[int]) -> int:
3
+ answer = 0
4
+
5
+ min_price = prices[0]
6
+ for price in prices:
7
+ if min_price>price:
8
+ min_price=price
9
10
+ if answer<price-min_price:
11
+ answer=price-min_price
12
+ return answer
0 commit comments