-->
当前位置:首页 > 题库

PROGRAMMING:Merge two ordered linked lists (the new list does not contain duplicate elements)

Luz5年前 (2021-05-10)题库451
Given two non descending linked list sequences S1 and S2, we design a function to construct a new non descending linked list S3 after merging S1 and S2.
No duplicate elements are required in S3.
###Input format:
The input is divided into two lines. In each line, a non descending sequence composed of several positive integers is given, and − 1 is used to represent the end of the sequence (− 1 does not belong to the sequence). The numbers are separated by spaces.
###Output format:
Output a new non descending linked list after merging in one row, which requires that there are no duplicate elements in the linked list. The numbers should be separated by spaces, and there should be no extra spaces at the end; If the new list is empty, output null.
###Input example:
Here is a set of inputs. For example:
```in
1 3 3 5 8 -1
2 3 4 6 8 10 -1
```
###Output example:
The corresponding output is given here. For example:
```out
1 2 3 4 5 6 8 10
```







answer:If there is no answer, please comment