Unable to detect the error in my code
What is the error in my code?
Hey, you should
- take input the number of testcases
int t; cin >>t; while(t–) … - insert at tail (not head)
- in merge_list use
head=h1; (in place of head->data= h1->data;)
and head=h2;
Your code will run fine!
done, but why does head = h1 works?
because initially head is not pointing to anyone
so head->data is not correct it may give run time error
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.