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.
It seems that whether a List-based solution passes the test suite at submission depends on how busy the servers are. When I tried, it was impossible to get through without the min/max heaps solution. Solution based on a soreted List has timed out over 50% of the tests (and it was even a bit more efficient than the above). Heaps, like PriorityQueue, are desigend to keep track of the min value efficiently (or the max value, depending on the Comparator you provide); I don't think you can beat them in time complexity.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Heaps: Find the Running Median
You are viewing a single comment's thread. Return to all comments →
It seems that whether a
List
-based solution passes the test suite at submission depends on how busy the servers are. When I tried, it was impossible to get through without the min/max heaps solution. Solution based on a soretedList
has timed out over 50% of the tests (and it was even a bit more efficient than the above). Heaps, likePriorityQueue
, are desigend to keep track of the min value efficiently (or the max value, depending on theComparator
you provide); I don't think you can beat them in time complexity.