


Input: 'a' = [2, 4, 6] and 'b' = [1, 3, 5]
Output: 3.5
Explanation: The array after merging 'a' and 'b' will be { 1, 2, 3, 4, 5, 6 }. Here two medians are 3 and 4. So the median will be the average of 3 and 4, which is 3.5.
The first line contains two space-separated integers ‘n’ and ‘m’ representing the sizes of the two arrays.
The second line contains 'n' space-separated integers representing the elements of the first array.
The third line contains 'm' space-separated integers representing the elements of the second array.
Print a single line containing a single value denoting the median of the combined array.
You do not need to print anything, it has already been taken care of. Just implement the given function and return the median of the two arrays.
The first approach is by joining the array and again sorting is to get median.
The algorithm is as follows:
The second approach is using a two-pointer approach to get middle elements.
The algorithm is as follows:
The third approach is using binary search to find median.
The algorithm is as follows: