Compute the median after each addition: [1]→median 1, [1,2]→median 1.5, [1,2,3]→median 2. Use two heaps (max-heap for smaller half, min-heap for larger half) for O(log n) addition and O(1) median.
Keywords
dsa
Python
Run your code to see results
No results yet
Run your code to check it against the examples, or submit to run every test.