Time: 35 ms (96.78%), Space: 28.7 MB (69.5%) - LeetHub

This commit is contained in:
Deven
2025-11-26 20:03:16 -05:00
parent 5f2c51e273
commit 1b166a19b6
@@ -10,7 +10,8 @@ class Solution:
# iterate over k+1...n - O(n) times
# - if larger than min in heap, replace min - O(log k)
# - else do nothing
for num in nums:
for i in range(k, len(nums)):
num = nums[i]
if num > heap[0]:
heapq.heapreplace(heap, num)