Search
⌘K

Leetcode 4. Median of Two Sorted Arrays

Find the median of two sorted arrays in O(log(m+n)) time by using binary search to partition the arrays so the left half contains the correct count of smaller elements and all left elements ≤ all right elements. The challenge is doing this efficiently without merging and handling unequal lengths and edge boundaries.

Asked at:

Microsoft

Microsoft

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early April, 2025

Meta

Senior

Late January, 2025

Microsoft

Microsoft

Intern

Median of two sorted arrays

Comments

Your account is free and you can post anonymously if you choose.