Code Room
CodingHardcod-g325
Subject Kth elementLevel Senior–Staff~38 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

You have k sorted ascending integer lists. Find the smallest range [a, b] that includes at least one number from each of the k lists. Return [a, b]. If multiple ranges have the same size, return the one with the smaller a. Constraints: 1 <= k <= 3500, each list 1..50 long, -10^5 <= values <= 10^5.

Implement
smallest_range(lists: list[list[int]]) → list[int]
Examples
in[[[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]]out[20,24]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.