Union Of Two Sorted Arrays

medium
1. Given two sorted arrays a[] and b[] of size n and m respectively. The task is to find union between these two arrays.
2. Union of the two arrays can be defined as the set containing distinct elements from both the arrays. If there are repetitions, then only one occurrence of element should be printed in union.
3. Your task is to complete Union function that takes a, b as parameters and returns an Arraylist which contains the union elements of the two arrays.The printing is done by the driver code.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1 <= n, m <= 10^5
1 <= a[i], b[i] < 10^5

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
6
1 2 2 3 3 4
4     
1 2 3 5
Output
1 2 3 4 5 
Previous
Marks Of Pcm
Next
Find Pivot Index

Related Questions