How to find union of two sorted array ?
[Question]: In a given two sorted array find union elements. Output should be sorted. For example : arr1[] = {1,2,3,4,5} arr2[] = {2,3,4,4,5} Output: {1,2,3,4,5}Approach #1: Use Dictionary / Hashset & after it sort the array which SC: O(m+n) TC: O( (m+n)log(m+n) ) Approach #2: Two pointer approach: use two pointer i & j & fill the […]
How to find union of two sorted array ? Read More »