Skip to content

Instantly share code, notes, and snippets.

@decagondev
Created April 23, 2025 21:12
Show Gist options
  • Save decagondev/2aadb2f0ee1376611730302e44fc3dac to your computer and use it in GitHub Desktop.
Save decagondev/2aadb2f0ee1376611730302e44fc3dac to your computer and use it in GitHub Desktop.

PROBLEM 4: Median of Two Sorted Arrays

Problem Statement

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

Concepts Covered

  • Binary Search
  • Divide and Conquer

Examples

Input: nums1 = [1, 3], nums2 = [2]
Output: 2.0

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

Starter Code

def find_median_sorted_arrays(nums1: list[int], nums2: list[int]) -> float:
    # Implement your solution here
    pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment