Problem of the day
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.
3 3
2 4 6
1 3 5
3.5
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.
3 2
2 4 6
1 3
3
The array after merging 'a' and 'b' will be { 1, 2, 3, 4, 6 }.
The median is 3.
3 3
1 2 2
2 4 4
2.0
The array after merging 'a' and 'b' will be { 1, 2, 2, 2, 4, 4 }.
Here two medians are 2 and 2. So the median will be the average of 2 and 2, which is 2.
1 <= 'n' <= 10 ^ 6
1 <= 'm' <= 10 ^ 6
1 <= 'a[i]' <= 10 ^ 9
1 <= 'b[i]' <= 10 ^ 9
Time limit: 1 sec.