Input: arr1[] = [11, 1, 8], arr2[] = [10, 11]
Output: [1, 8, 10, 11]
Explanation: The ouput array after merging both the arrays and removing duplicates is [1 8, 10, 11].
Input: arr1[] = [7, 1, 5, 3, 9], arr2[] = [8, 4, 3, 5, 2, 6]
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Explanation: The ouput array after merging both the arrays and removing duplicates is [1, 2, 3, 4, 5, 6, 7, 8, 9].
First, sorts both input arrays individually. Then, merge them into a result array by comparing elements one by one from both sorted arrays, maintaining the overall sorted order. Any remaining elements from either array are appended after one finishes.