Skip to content

Commit af156da

Browse files
committed
Time: 95 ms (79.85%), Space: 23.2 MB (99.24%) - LeetHub
1 parent 2d7a39d commit af156da

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def maxProfit(self, prices: List[int], fee: int) -> int:
3+
buy = float('-inf')
4+
sell = 0
5+
6+
for price in prices:
7+
buy = max(buy, sell - price)
8+
sell = max(sell, buy + price - fee)
9+
10+
return sell

0 commit comments

Comments
 (0)