Pls help me in finding error

see basically,

nodehead1=NULL;
node
head2=NULL;

The above statements should lie inside your loop
for(n=0; n<t; n++)
because head1 and head2 should be initialsed for every test case,

Also, the statement inside your function should be
if(a->data<=b->data)

[put an = sign to handle all cases]

make these changes, hope it works!

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.