yan chuanli 2 rokov pred
rodič
commit
0ac0c7a7a7
1 zmenil súbory, kde vykonal 14 pridanie a 0 odobranie
  1. 14 0
      array/max_profit.py

+ 14 - 0
array/max_profit.py

@@ -0,0 +1,14 @@
+from typing import List
+import heapq
+
+def maxProfit(prices: List[int]) -> int:
+    inf = int(1e9)
+    min_price = inf
+    max_profit = 0
+    for price in prices:
+        max_profit = max(price - min_price, max_profit)
+        min_price = min(price, min_price)
+    return max_profit
+
+
+