Not get correct output

code link:https://ide.codingblocks.com/s/140943

Hi Rohan,
In your merge_sorted_list you need to use only 1 if statement. In the code snippet below from your code:

if(temp.data<other.head.data){
tail.next=temp;
temp=temp.next;
}
if(temp.data>other.head.data){
tail.next=other.head;
other.head=other.head.next;
}
tail=tail.next;

After the first if statement is executed and the second if statement is also true, it will overwrite you current data because tail has not been updated yet. Instead use a if - else statement block for simplicity.

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.