What's wrong with this code it showing MLE on submission

#include
using namespace std;

class node{
public:
int data;
node* next;
node(int d){
data=d;
next=NULL;

  }

};

node* Linked_list(node*& head1,int n){
node* tail=NULL;
int d;
cin>>d;
node* x = new node(d);
head1=tail=x;
n=n-1;
while(n–){
cin>>d;
x = new node(d);
tail->next = x;
tail=x;
}
return head1;
}

node* merge(node* a,node* b){
if(a==NULL){
return b;
}
if(b==NULL){
return a;
}
node* c;
if(a->data < b->data){
c = a;
c->next = merge(a->next,b);
}else{
c = b;
c->next = merge(a,b->next);

}
return c;

}

int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
node* head1=NULL;
head1 = Linked_list(head1,n);

	node* head2 = NULL;
	int m;
	cin>>m;
	head2 = Linked_list(head2,m);

	node* temp = merge(head1,head2);
	
	

	while(temp!=0){
		cout<<temp->data<<" ";
		temp=temp->next;
	}

}
return 0;

}

Hey @krishav49
This should be temp!=null
If this doesn’t work then please dhare ur code in Coding Blocks Ide

Otherwise please mark it as resolved if this resolves ur query

Not working
code on coding block ide

code_of_merge_two_sorted_linked_list

Hey @krishav49
Did 2 changes (1 in main and another in Linked_list function) : https://ide.codingblocks.com/s/373585
Mentioned them in comments :slight_smile:

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.