Can i use this code,for the problem merge two sorted arrays without extra space.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ll t,i;
cin>>t;
while(t–){
ll m,n,i;
cin>>m>>n;
ll l=m+n;
ll a[l];
for( i=0;i<l;i++){
cin>>a[i];
}
sort(a,a+l);
for( i=0;i<l;i++){
cout<<a[i]<<" ";
}
cout<<endl;
}
return 0;
}
sample input:-
2
4 5
1 3 5 7
0 2 6 8 9
2 3
10 12
5 18 20
Sample output:-
0 1 2 3 5 6 7 8 9
5 10 12 18 20
My code is accepted ,but i dont know whether it is correct or wrong approach.