Please help me get rid of TLE.
Merge sorted linked lists problem
Hey @apoorvas1301
Initialize both head as null inside while(t–) loop
Otherwise LL of e very testcase will keep connecting
If I do that,I m getting all the testcases wrong.
int main() {
// node* head1=NULL;do inside loop
// node* head2=NULL;
node* head;
ll int t;
cin>>t;
while(t--)
{
node* head1=NULL; //do here
node* head2=NULL;
ll int n1,n2;
cin>>n1;
takeinput(head1,n1);
cin>>n2;
takeinput(head2,n2);
head=merge(head1,head2);
print(head);
cout<<endl;//add this
}
return 0;
}
If resolves ur query then please mark it as resolved 
Its working now,thank you.
1 Like