We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1a95812 commit 83a10abCopy full SHA for 83a10ab
121-Best-Time-To-Buy-and-Sell-Stock.py
@@ -0,0 +1,10 @@
1
+class Solution:
2
+ def maxProfit(self, prices: List[int]) -> int:
3
+ res = 0
4
+
5
+ l = 0
6
+ for r in range(1, len(prices)):
7
+ if prices[r] < prices[l]:
8
+ l = r
9
+ res = max(res, prices[r] - prices[l])
10
+ return res
0 commit comments