Merge Sorted Linked Lists java

I’m getting the correct answer, but it is not accepting all the test cases.
I can’t even access the test cases and editorial.

Hi Aman

Please share the link to your code.

Hi Aman,
Your code will not work in case where 1st element of a linked list is greater than 2nd element of other linked list. Such as
linked list 1: 1 2 3 4 5
linked list 2: 6 7 8 9 10

the correct output will be: 1 2 3 4 5 6 7 8 9 10
but your code will print: 1 6 2 7 3 8 4 9 5 10 which is wrong.

1 Like

that solved it - thank you

Hi Aman

I am marking your doubt as resolved. Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.