#C12825. Merge Two Sorted Linked Lists
Merge Two Sorted Linked Lists
Merge Two Sorted Linked Lists
You are given two sorted linked lists (l_1) and (l_2). Your task is to merge them into a single sorted linked list. The resulting list should maintain the sorted order. It is guaranteed that each input list is sorted in non-decreasing order. This problem tests your understanding of linked lists and two-pointer techniques.
inputFormat
The input consists of two lines:\
- The first line contains zero or more integers separated by spaces, representing the first sorted linked list ((l_1)).\
- The second line contains zero or more integers separated by spaces, representing the second sorted linked list ((l_2)).\ An empty line represents an empty list.
outputFormat
Output the merged sorted linked list as space-separated integers on a single line. If the resulting list is empty, output nothing.## sample
1 3 5
2 4 6
1 2 3 4 5 6