Smallest range from k lists
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.
0:00 of about 38 min
solution.py
InputExpectedGot
[[[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]][20,24]not run yetsample