+ 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.
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.