ASAPUtils Logo ASAPUtils
Week 4

Median of Two Sorted Arrays

Median of Two Sorted Arrays derived from balanced partitions, with sentinel boundaries, logarithmic search on the shorter array, C++ and JavaScript solutions, correctness conditions, and a two-row partition visualizer.

hard Arrays Binary Search O(log(min(m,n))) time · O(1) space Open on LeetCode ↗

The problem

Given two individually sorted arrays, return the median of all their values with required time complexity O(log(m+n)).

nums1 = [1,3], nums2 = [2] -> 2.0

Related Problems