is there another method so that i can remove tle from it and basically due to which line i am getting tle
It is giving me 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
- 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. - In merge function, when
head->val <= head1->valyou have to call onhead->nextbecauseheadnode was assigned toc, instead you are calling onhead1->next. - In
print()function, your output is not matching the sample output.
even after making the above given changes ,i am still getting tle
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.