#K55442. Merge Two Sorted Linked Lists

    ID: 29976 Type: Default 1000ms 256MiB

Merge Two Sorted Linked Lists

Merge Two Sorted Linked Lists

You are given two sorted linked lists. Your task is to merge them into a single sorted linked list. The resulting list should be sorted in non-decreasing order. The expected time complexity of your solution is \(O(n+m)\), where \(n\) and \(m\) are the lengths of the two linked lists.

For example, merging the lists [1, 2, 4] and [1, 3, 4] should result in [1, 1, 2, 3, 4, 4].

inputFormat

The input is given via standard input (stdin) in the following format:

<n>
<n> space-separated integers (the first sorted linked list; if n is 0, the line will be empty)
<m>
<m> space-separated integers (the second sorted linked list; if m is 0, the line will be empty)

outputFormat

Output the merged sorted linked list in one line as space-separated integers to standard output (stdout). If the merged list is empty, output an empty line.

## sample
0

0