Z45

Smallest Range Covering Elements from K Lists

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

Problem Statement & Objective

You have k lists of sorted integers. Find the smallest range that includes at least one number from each of the k lists.

Function Signature (Python)

smallest_range_covering_elements_from(lists: list[list[int]]) -> list[int]

Input & Output Contract

Output Rule:[a, b] formatında 2 elemanlı liste.

System Constraints

k == listeler.length
1 <= k <= 3500
1 <= listeler[i].length <= 50
-10^5 <= sayilar <= 10^5

Example Execution Walkthrough

listeler = [[4,10,15,24,26], [0,9,12,20], [5,18,22,30]]
[20, 24] aralığı 20'yi 2. listeden, 22'yi 3. listeden, 24'ü 1. listeden içerir -> [20, 24]

Example Test Scenarios (3)

Example 1
Input:[[[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]]
Expected Output:[20,24]
Example 2: Nokta Aralık
Input:[[[1,2,3],[1,2,3],[1,2,3]]]
Expected Output:[1,1]
Example 3: Bitişik
Input:[[[10,10],[11,11]]]
Expected Output:[10,11]
Loading Python Editor...
Input Parameters
[
  [
    [
      4,
      10,
      15,
      24,
      26
    ],
    [
      0,
      9,
      12,
      20
    ],
    [
      5,
      18,
      22,
      30
    ]
  ]
]
Expected Output
[
  20,
  24
]