Problem
Input format
The program reads from standard input: - a natural number `n`, followed by `n` integers (array `a`, sorted in non-decreasing order); - a natural number `m`, followed by `m` integers (array `b`, sorted in non-decreasing order). - `1 <= n, m <= 1000` - `-1000000 <= values <= 1000000` - the arrays are sorted in non-decreasing order but may contain duplicates
Output format
The program prints on the first line the number `k` of distinct values in the union, and on the second line the `k` values in non-decreasing order, separated by a single space. Both lines end with a newline.
Example
5 1 3 5 7 9 4 2 4 6 8
9 1 2 3 4 5 6 7 8 9
Stuck?
Use the Get Hint button in the action bar to reveal a guided hint.
💬 Discussion
Loading...No comments yet. Be the first to start the discussion!
Sample cases (from the problem)
Sample Case 1
5 1 3 5 7 9 4 2 4 6 8
9 1 2 3 4 5 6 7 8 9
Solve it your way first
Community solutions unlock after you submit a passing solution. Don't peek.
Ready to solve this challenge?
Create a free account to write code, submit solutions, and track your progress.