Median of Two Sorted Arrays

Hard

📝 Description

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

Input Format

Line 1: m n (sizes of arrays) Line 2: m space-separated integers (nums1) Line 3: n space-separated integers (nums2)

Output Format

A single floating point number (median)

Constraints

nums1.length == m nums2.length == n 0 ≤ m ≤ 1000 0 ≤ n ≤ 1000 1 ≤ m + n ≤ 2000

🔍 Sample Input

2 1
1 3
2
            

✅ Sample Output

2.0
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run