Code gives wrong answer

my code gives wrong answer int all test cases but for given example it gives desired output. problem: merge two linked lists

https://online.codingblocks.com/app/player/57623/content/27242/4759/code-challenge

Hey @roopenmangat please share your code through ide.codingblocks.com

Bhaiya mail krna h code

Follow these steps

  1. open ide.codingblocks.com
  2. paste your code
  3. click on the save
  4. copy the link and paste it here.

The problem is that if head1 or head2 becomes NULL you insert the next element of the one who hasnt become NULL, So for example if one linked list is 1,2 and the second linked list is 3, 4 your code would return 1, 2, 3.
So you need to replace the if with while

if(head1!=NULL) would change to while(head1!=NULL)

and

if(head2!=NULL) would change to while(head2!=NULL)

okk done .
thanks a lot

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.