Skip to content

Commit 7d0a877

Browse files
author
nikumu
committed
004
1 parent d5852ff commit 7d0a877

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# 4. Median of Two Sorted Arrays
2+
3+
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
4+
5+
The overall run time complexity should be O(log (m+n)).
6+
7+
8+
### Example 1:
9+
10+
**Input:** nums1 = [1,3], nums2 = [2]
11+
**Output:** 2.00000
12+
**Explanation:** merged array = [1,2,3] and median is 2.
13+
14+
15+
### Example 2:
16+
17+
**Input:** nums1 = [1,2], nums2 = [3,4]
18+
**Output:** 2.50000
19+
**Explanation:** merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
20+
21+
22+
### Constraints:
23+
24+
- nums1.length == m
25+
- nums2.length == n
26+
- 0 <= m <= 1000
27+
- 0 <= n <= 1000
28+
- 1 <= m + n <= 2000
29+
- -10⁶ <= nums1[i], nums2[i] <= 10⁶
30+
31+

0 commit comments

Comments
 (0)