Back to problems

Median of Two Sorted Arrays

Algorithm · Rippling · Hard

Coding Software Engineer, Machine Learning Engineer You are given two nondecreasing integer arrays, nums1 and nums2, whose lengths are m and n. Determine the median of all elements from both arrays combined. Your solution must run in O(log(m+n)) time overall. Examples Example 1: Input: nums1 = [2,6], nums2 = [4] Output: 4.00000 Explanation: The combined ordered sequence is [2,4,6], so its middle value is 4. Example 2: Input: nums1 = [2,5], nums2 = [7,9] Output: 6.00000…

Checking your access…