Heaps: Find the Running Median

  • + 0 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());
                }
            }
        }