1p3a Question · Feb 2026

Median of Two Sorted Arrays

Question Details

Median of Two Sorted Arrays

Problem Statement You are given two sorted arrays, nums1 and nums2. The size of the first array is m and the size of the second array is n. Your task is to fin

Full Details

Median of Two Sorted Arrays

Problem Statement You are given two sorted arrays, nums1 and nums2. The size of the first array is m and the size of the second array is n. Your task is to find the median value of these two arrays. You must design a solution that is very fast. The time complexity must be O(log(m+n)).

Sample Cases

Case 1 *

Input: nums1 = [1,3], nums2 = [2] *

Output: 2.00000 *

Why: If you merge the arrays, you get [1, 2, 3]. The median is 2.

Case 2 *

Input: nums1 = [1,2], nums2 = [3,4] *

Output: 2.50000 *

Why: If you merge the arrays, you get [1, 2, 3, 4]. The median is the average of 2 and 3, which is 2.5.

Input Limits * nums1 has a length of m. * nums2 has a length of n. * m and n are between 0 and 1000. * The total size (m + n) is at least 1 and no more than 2000. * The values inside the arrays range from -1,000,000 to 1,000,000. ## Company Tags

About This Question

This is a reported interview question from a rippling interview for a swe role reported in 2025.

It covers the following topics: Array, Arrays .