Median of Sorted Arrays
We are given two sorted arrays of same size n. Find the median of an array formed after merging these two sorted arrays.
Median of Sorted Arrays
We are given two sorted arrays of same size n. Find the median of an array formed after merging these two sorted arrays.
Brother there is no need of recursion here.
Please try solving the problem in O(n).
Hint: use 2 iterators on the 2 arrays until iterations on both of them combined reaches the medians’s location.
EXTRA SUGGESTION :
Instead of
cin >> z ;
a[i] = z ;
Just simply do
cin >> a[i] ;