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 guess I am not understanding the question properly. We are to calculate the median after each streaming number. I am confused that we need to create heaps and store the values according. Unless we read all the data first and put the ones below median in the min-heap and the ones above the median in max heap and then pop them into a list and calcualte the medians as we do. Am I totally off. My original solution works for the first test and fails all the rest.
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 →
I guess I am not understanding the question properly. We are to calculate the median after each streaming number. I am confused that we need to create heaps and store the values according. Unless we read all the data first and put the ones below median in the min-heap and the ones above the median in max heap and then pop them into a list and calcualte the medians as we do. Am I totally off. My original solution works for the first test and fails all the rest.