+ 1

Given two arrays one with m elements and one with n elements.

Given two arrays one with m elements and one with n elements. Find median of the two arrays if combined. m and n is different sizes. Give the most optimized solution with O(1) space complexity and minimum time complexity.

26th Oct 2017, 6:31 PM
Biswarup dutta
Biswarup dutta - avatar
1 Answer
+ 3
if (m + n) / 2 Is the index of the median, call it e, then: if(e < m) array[e] = median value. else array2[e - m] = median value.
26th Oct 2017, 6:42 PM
Rrestoring faith
Rrestoring faith - avatar