Understand "Merge two sorted linked lists" on hackerrank

Viewed 8

(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

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?
1 Answers

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

Related