Z52

Median of Two Sorted Arrays

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

Problem Statement & Objective

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays in O(log (m+n)) runtime.

Function Signature (Python)

find_median_sorted_arrays(nums1: list[int], nums2: list[int]) -> float

Input & Output Contract

Output Rule:Medyan değeri (float veya tamsayı).

System Constraints

0 <= m, n <= 1000
1 <= m + n <= 2000
-10^6 <= sayilar1[i], sayilar2[i] <= 10^6

Example Execution Walkthrough

sayilar1 = [1, 3], sayilar2 = [2] -> birleşik [1, 2, 3] -> medyan 2.0
sayilar1 = [1, 2], sayilar2 = [3, 4] -> birleşik [1, 2, 3, 4] -> (2 + 3) / 2 = 2.5

Example Test Scenarios (3)

Example 1: Tek Sayıda
Input:[[1,3],[2]]
Expected Output:2
Example 2: Çift Sayıda
Input:[[1,2],[3,4]]
Expected Output:2.5
Example 3: Sıfırlar
Input:[[0,0],[0,0]]
Expected Output:0
Loading Python Editor...
Input Parameters
[
  [
    1,
    3
  ],
  [
    2
  ]
]
Expected Output
2