Median of Two Sorted Arrays

There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

Binary search. Each time we could eliminate half of the A or half of the B.

Note that if m + n is even, we need to return the mean value of (m+n)/2 and (m+n)/2+1.

Comments

Popular posts from this blog

Maximum Gap

[ITint5] Maximum Subarray for a Circular Array

[CC150] Chapter 4 Trees and Graphs