Merge two sorted slices with duplicate removal
Go
Medium
slices
Task «Merge two sorted slices with duplicate removal»
Given two slices of integers sorted in ascending order. Merge them into one sorted slice, removing all duplicates. Implement the function MergeSortedUnique(a, b []int) []int, which takes two slices and returns a new slice. Input data is read from stdin: first the length of the first slice, then its elements, then the length of the second slice and its elements. Output the resulting slice separated by spaces.
Input Format
First line: integer n (0 ≤ n ≤ 1000) — the length of the first slice. Second line: n integers sorted in ascending order. Third line: integer m (0 ≤ m ≤ 1000). Fourth line: m integers sorted in ascending order.
Output Format
One line: elements of the resulting slice, sorted in ascending order, without duplicates, separated by a space.
Examples
Example 1
INPUT
3
1 1 2
3
1 2 3
OUTPUT
1 2 3
Example 2
INPUT
3
0 0 1
OUTPUT
3
main.go