Skip to content

Commit 8cbcf1d

Browse files
authored
Update sliding-window-median.py
1 parent ab9ff35 commit 8cbcf1d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Python/sliding-window-median.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def rebuild_heap(heap, to_remove, sign): # Time: O(k), Space: O(k)
6868
if not to_remove[min_heap[0]]:
6969
del to_remove[min_heap[0]]
7070
heapq.heappop(min_heap)
71-
if len(min_heap)+len(max_heap) > 2*k:
71+
if len(min_heap)+len(max_heap) > 2*k: # full delete
7272
rebuild_heap(max_heap, to_remove, -1)
7373
rebuild_heap(min_heap, to_remove, 1)
7474
result.append(float(min_heap[0]) if k%2 else (min_heap[0]-max_heap[0])/2.0)

0 commit comments

Comments
 (0)