#C2628. Merge Two Sorted Lists
Merge Two Sorted Lists
Merge Two Sorted Lists
You are given two sorted lists of integers in ascending order. Your task is to merge these two lists into a single sorted list maintaining the ascending order.
The merging process is a classic algorithm used in merge sort. Given two lists (A) and (B), the goal is to produce a new list (C) such that all elements from (A) and (B) are arranged in ascending order.
inputFormat
The input consists of four lines:
- The first line contains an integer (n), the number of elements in the first list.
- The second line contains (n) space-separated integers representing the first sorted list.
- The third line contains an integer (m), the number of elements in the second list.
- The fourth line contains (m) space-separated integers representing the second sorted list.
outputFormat
Print a single line containing the merged sorted list with its elements separated by a single space.## sample
3
1 3 5
3
2 4 6
1 2 3 4 5 6