Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Understand "Merge two sorted linked lists" on hackerrank

(migrated from Code Golf)

The question comes from the HackerRank problem Merge two sorted linked lists:

Sample Input
1
3
1
2
3
2
3
4
Sample Output
1 2 3 3 4 
Explanation

The first linked list is: 1→3→7→Null
The second linked list is: 3→4→Null
Hence, the merged linked list is: 1→2→3→3→4→Null

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have two questions:

  1. How does the sample input correspond to the explanation section? There is no "7".
  2. In the explanation,
    "The first linked list is: 1->3->7->Null"
    but in the merged list there is no "7". Why does "7" disappear?

>Solution :

It’s a mistake. The first linked list is: 1→2→3→Null

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading