Back to course home
0% completed
Median of Two Sorted Arrays (hard)
Problem Statement
Given two sorted arrays, nums1
and nums2
of different sizes in the ascending order, return the median of two sorted arrays after merging them.
The median is the middle value in an ordered set, or the average of the two middle values if the set has an even number of elements.
Examples
-
Example 1:
- Input:
[1, 3, 5]
and[2, 4, 6]
- Expected Output:
3.5
- Justification: When merged, the array becomes
[1, 2, 3, 4, 5, 6]
. The median is the average of the middle two values,(3 + 4) / 2 = 3.5
.
- Input:
-
Example 2:
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible