Back to course home
0% completed
Vote For New Content
Solution: Smallest Range Covering Elements from K Lists
Problem Statement
You are given k
lists of sorted integers. Each list is in non-decreasing order.
Find the smallest range that includes at least one number from each of these k
lists. The range [a, b]
is smaller than range [c, d]
if b - a < d - c
or a < c
if b - a == d - c
.
Examples
Example 1:
- Input: nums =
[[1, 5, 8], [4, 12], [7, 8, 10]]
- Expected Output:
[4, 7]
- Justification: The range [4, 7] includes 5, 4, and 7 numbers from the first, second and third list respectively.
Example 2:
- Input: nums =
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page