Skip to content

Commit 8f2bd51

Browse files
committed
🎉 [q4] Median of Two Sorted Arrays
1 parent 6eaeef8 commit 8f2bd51

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

4/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
https://leetcode.com/problems/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+
- -106 <= nums1[i], nums2[i] <= 106

4/my_solution.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @param {number[]} nums1
3+
* @param {number[]} nums2
4+
* @return {number}
5+
*/
6+
const findMedianSortedArrays = (nums1, nums2) => {
7+
// TODO:
8+
};

0 commit comments

Comments
 (0)