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.
Constraints
1 <= n, m <= 10^5 1 <= a[i], b[i] < 10^5
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
6
1 2 2 3 3 4
4
1 2 3 5
Sample Output
1 2 3 4 5
Question Video