Merge sorted linked list

I am getting a TLE


I guess because the way i am taking the input

I modified your code a bit. Check it out -


The statements node* head1 = NULL and node *head2 = NULL in int main() should be included within the while loop because we need two new linked lists for each test case.

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.