Merge sorted linked list
@AjayRRJ
Actually the way you are taking input linked list is wrong. Your code needs “-1” at the end of linked list but in the given inputs, you don’t have “-1” at the end. See sample testcase. That’s why your code get stuck in infinite loop.
modify the code . Actually I am not getting it.
after using correct input still tle error modify this code
Let me check your code.
@AjayRRJ
Do the following changes in your code , it’ll work
1)change line 56 to cout<data<<" "; you don’t have to print “->”
2)comment out line 65 to 69, and simple write insertAttail(head,data); after line 64
3)remove line 93, you already did n1-- in line 90
4) initialize head and head2 to NULL inside while loop.
Thanks bhaiya it works . In the question u need not input -1 i.e why skip line 65 to 69
You’re welcome. Mark it as resolved.