Error
|
|
---|---|
@Ibrahim Nash | 6420 |
@blackshadows | 6376 |
@mb1973 | 5594 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@kirtidee18 | 3673 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3412 |
Complete Leaderboard | |
|
|
@codersgroup18 | 783 |
@Manikanta punnam | 605 |
@sriramgoparaju99 | 582 |
@rdakka | 534 |
@praveenbgp6 | 529 |
@prankursharma31 | 518 |
@yashkaril4 | 517 |
@purohitmn02 | 467 |
@sonamnigam1999 | 443 |
@sonamkumari63928 | 441 |
@shubhamstudent5 | 433 |
Complete Leaderboard |
Given two sorted arrays array1 and array2 of size m and n respectively. Find the median of the two sorted arrays.
Example 1:
Input:
m = 3, n = 4
array1[] = {1,5,9}
array2[] = {2,3,6,7}
Output: 5
Explanation: The middle element for
{1,2,3,5,6,7,9} is 5
Example 2:
Input:
m = 2, n = 4
array1[] = {4,6}
array2[] = {1,2,3,5}
Output: 3.5
Your Task:
The task is to complete the function MedianOfArrays() that takes array1 and array2 as input and returns their median.
Expected Time Complexity: O(min(log n, log m)).
Expected Auxiliary Space: O(1).
Constraints:
0 <= m,n <= 10000
1 <= array1[i], array2[i] <= 10^5
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes