Merge two binary Max heaps Geeks For Geeks
Problem Link: https://practice.geeksforgeeks.org/problems/merge-two-binary-max-heap0144/1# It is also the problem of the day for Solution: class Solution{ public int[] mergeHeaps(int[] a, int[] b, int n, int m) { PriorityQueue<Integer>pq=new PriorityQueue<Integer>(Collections.reverseOrder()); for(int i=0;i<a.length;i++){ pq.add(a[i]); } for(int j=0;j<b.length;j++){ pq.add(b[j]); } int arr[]=new int[pq.size()]; int index=0; while(!pq.isEmpty()){ arr[index++]=pq.remove(); } return arr; } } TOTAL TEST CASES:10037 TIME COMPLEXITY:O(Max...