Median of Two Sorted Arrays
Hard
Arrays
Binary Search
Find the median of two sorted arrays in O(log(m+n)).
Input: two lines of space-separated sorted numbers
Output: median
Constraints
See problem-specific constraints. Optimized solution required.
Examples
Example 1:
Input: 1 3
2
Output:
Example 2:
Input: 1 3
2
Output:
Hints
Consider a binary search approach.
Think about time complexity.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console