Skip to content

[Algo] Median of Two Sorted Arrays #56

@Jeanedlune

Description

@Jeanedlune

Problem: Median of Two Sorted Arrays

Find the median of two sorted arrays.

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

Constraints

  • nums1.length == m
  • nums2.length == n
  • 0 <= m <= 1000
  • 0 <= n <= 1000
  • 1 <= m + n <= 2000
  • -10^6 <= nums1[i], nums2[j] <= 10^6

Example

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

Complexity

  • Time: O(log(min(m, n)))
  • Space: O(1)

Contribution Guidelines

  • Implement in one language (we'll add others later)
  • Include README with problem statement and test cases
  • Add test harness in your implementation
  • Follow code style guide in .gemini/styleguide.md

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions