I got wrong answer .Please tell what is wrong in my code.
My code is give below:
Doubt in merge sorted linked lists
Hello @76rahul257,
Your code is failing for the test cases like:
Example 1:
1
2
1 1
2
-1 2
Expected Output:
-1 1 1 2
Your Output:
1 1 2
Example 2:
1
2
1 1
2
1 1
Expected Output:
1 1 1 1
Your Output:
1 1
Hope, this would help.
Give a like if you are satisfied.
Please, Tell what i do for negative inputs.
Hey @76rahul257
Your code is logically correct but you are passing the wrong pointer to the print function.
How are you so sure that the first node of the merged list will be head?
I have modified your code:
Hope, this would help.
Give a like if you are satisfied.
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.