Merge Linked lists doubt


This code is showing declaration errors.

hi @srshubhi398 same mistake as prev code, you forgot to write the “node” class

thanks a lot.I understood.

1 Like

@srshubhi398 please mark the doubts as resolved :slight_smile:

but after this it is showing run error now.

@srshubhi398 share the updated code please


this is it.

hi @srshubhi398

  1. there are multiple test cases in the question, your program is for 1 test case only. Take input t and run the program for each test case.
  2. You are doing cout << head head is a pointer, so it stores a head. When you directly print head like this, it will print the address of head. Call the print() function for head.

I shall try.Thankyou

1 Like


still the wrong answer.

@srshubhi398 buildlist function was wrong. you are taking input later but already inserted the value? How can you do that…first you take user input THEN you insert it in the list.
Secondly, do not print arrows in the print function.
corrected code:

1 Like

Thank you very much for explaining my mistakes and correcting the code.

1 Like

@srshubhi398 dont forget to mark your doubt as resolved :slight_smile: