You are viewing a single comment's thread. Return to all comments →
Thanks for the inspiration, your code is very neat!! In my humble view, balance can be optimized a little bit:)
//Balance O(1) static void balance(){ if(Math.abs(low.size() - high.size()) > 1){ if(low.size() > high.size()){ high.add(low.poll()); }else{ low.add(high.poll()); } } }
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 →
Thanks for the inspiration, your code is very neat!! In my humble view, balance can be optimized a little bit:)