Question : Merge two sorted array without extra space;

https://practice.geeksforgeeks.org/problems/merge-two-sorted-arrays/0

My approach;

i used second array B as a min heap. For each element in A (size n) , i compared it with

B[0], if i A[i] is greater than B[0] each time ,then i swapped it. and maintained my min heap B (size m) ( using make_heap in log m);

so my complexity should be n*logm and with given constraints ( n,m < 5x10^4) my code should calculate in < 1sec ??