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.
Keeping all elements in a max heap only allows quick access to the maximum integer, not the median. Likewise, keeping all elements in a min heap allows quick access to only the minimum element. However, if you put some elements in a min heap andsome in a max heap, you might be able to find the median quickly. What integers should you store in the min heap? Which should you store in the max heap? How many should each heap hold?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Running Median
You are viewing a single comment's thread. Return to all comments →
Keeping all elements in a max heap only allows quick access to the maximum integer, not the median. Likewise, keeping all elements in a min heap allows quick access to only the minimum element. However, if you put some elements in a min heap and some in a max heap, you might be able to find the median quickly. What integers should you store in the min heap? Which should you store in the max heap? How many should each heap hold?