Skip to content

Commit f4f236e

Browse files
authored
Merge pull request #2041 from XIAOLONGLII/patch-1
Better variable name
2 parents 882187d + e10ce4e commit f4f236e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class Solution:
22
def maxProfit(self, prices: List[int]) -> int:
33
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])
4+
5+
lowest = prices[0]
6+
for price in prices:
7+
if price < lowest:
8+
lowest = price
9+
res = max(res, price - lowest)
1010
return res

0 commit comments

Comments
 (0)