Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
Coding Round 2 Mid-Level programming

LeetCode #4 - Median of Two Sorted Arrays

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(min(m,n))). For example, given nums1 = [1, 3] and nums2 = [2], the median is 2.0. You need to implement the function double findMedianSortedArrays(int[] nums1, int[] nums2) that returns this value.
Example 1:
Input: nums1 = [1, 3], nums2 = [2]
Output: 2.00000
Example 2:
Input: nums1 = [1, 2], nums2 = [3, 4]
Output: 2.50000
Explanation: The median is (2 + 3)/2 = 2.5.
Constraints:
m == nums1.length, n == nums2.length
0 <= m <= 1000
0 <= n <= 1000
-10^6 <= nums1[i], nums2[i] <= 10^6.
Suggested Answer

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free

More Coding Round 2 Interview Prep

LeetCode #3 - Longest Substring Without Repeating Characters
Coding Round 1 · Mid-Level
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Link copied to clipboard