Skip to main content
Hard Binary Search High frequency

Median of Two Sorted Arrays

Open on LeetCode

Approach Summary

Binary search on the partition of the shorter array such that the left half of both arrays combined equals the right half.

How to Recognize This Pattern

  • Merge-and-find would be O(m+n) — hard wants O(log)
  • Think about partition indices, not merge

Complexity Analysis

Time Complexity

O(log(min(m, n)))

Space Complexity

O(1)

Tags

Array Binary Search Divide and Conquer

This site is free. If these guides are helping your prep, consider buying me a coffee. ☕

Support →
Buy me a coffee