It is giving me tle

is there another method so that i can remove tle from it and basically due to which line i am getting tle

@anyamaurya there were a number of errors in your code. I have made all ther required changes here https://ide.codingblocks.com/s/256520 for your reference

  1. In buildList() function, the while loop will end up taking an extra input, so the first element of next list is being consumed by it.
  2. In merge function, when head->val <= head1->val you have to call on head->next because head node was assigned to c, instead you are calling on head1->next.
  3. In print() function, your output is not matching the sample output.

even after making the above given changes ,i am still getting tle

@anyamaurya share the updated code please by saving it on cb ide

@anyamaurya you are printing two spaces instead of one in the output, that might be giving WA.

it still giving me tle

@anyamaurya since there are multiple test cases, you need to initialise head and head1 with NULL each time, https://ide.codingblocks.com/s/258252 try submitting this code it should work fine now.

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.