Code not getting submitted!

#include
using namespace std;
class node{
public:
node* next;
int data;
node(int d){
data = d;
next = NULL;
}
};
node* sortedMerge(node* a,node* b){
node* result = NULL;
if(a==NULL){
return b;
}
if(b==NULL){
return a;
}
if(a->data <= b->data){
result = a;
result->next = sortedMerge(a->next,b);
}
else if(b->data <= a->data){
result = b;
result->next = sortedMerge(a,b->next);
}
return result;
}
// node* midPoint(node*&head){
// node* fast = head;
// node* slow = head;
// while(fast!=NULL && fast->next!=NULL){
// fast = fast->next->next;
// slow = slow->next;
// }
// return slow;
// }
void print(node*&head){
node* temp = head;
while(temp!=NULL){
cout<data<<" ";
temp=temp->next;
}
}
void insertAtTail(node*&head,int d){
if(head==NULL){
head = new node(d);
return ;
}
node* temp = head;
while(temp->next!=NULL){
temp=temp->next;
}
temp->next = new node(d);
return;
}
void buildList(node*&head,int n){
node* temp = head;
int data=0;
while(n>0){
cin>>data;
insertAtTail(head,data);
n–;
}
}
int main() {
int t,n,m;
node* head = NULL;
node* head2 = NULL;
cin>>t;
while(t–){
cin>>n;
buildList(head,n);
cin>>m;
buildList(head2,m);
node* c = sortedMerge(head,head2);
print©;

}
return 0;

}

Hey could you please provide your code in Coding Blocks IDE.

https://ide.codingblocks.com/s/185879

You did some minor mistakes, you were not decrementing n. Also you need to print new line after every test case. And few other minor mistakes, I have corrected them have a look.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.