Adding the values of B [ ] into max heap
for ( let i = 0 ; i < N ; i ++ ) { pq2 . push ( B [ i ] ) ; } pq1 . sort ( function ( a , b ) { return a - b ; } ) ; pq1 . reverse ( ) ; pq2 . sort ( function ( a , b ) { return a - b ; } ) ; pq2 . reverse ( ) ;