We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I first used bisect.insort, it makes too easy for this problem. then I wrote my own version of binary search for insertion. and the performance is also good enough to pass all the tests.
it might be two times slower than using two sorted arrays, but it is in the same scale of performance with much cleaner solution.
Heaps: Find the Running Median
You are viewing a single comment's thread. Return to all comments →
I first used bisect.insort, it makes too easy for this problem. then I wrote my own version of binary search for insertion. and the performance is also good enough to pass all the tests.
it might be two times slower than using two sorted arrays, but it is in the same scale of performance with much cleaner solution.