Skip to content
C

Merge Two Sorted Linked Lists

Easyjavapythonccppjavascript

Given two sorted singly linked lists, merge them into one sorted linked list and print it.

Input Format

The first line contains an integer N. The second line contains N space-separated integers in non-decreasing order (list A; empty if N is 0). The third line contains an integer M. The fourth line contains M space-separated integers in non-decreasing order (list B; empty if M is 0).

Output Format

Print the merged sorted list, separated by single spaces. Print an empty line if both lists are empty.

Input (stdin)

Output

Run your code to see output here...