Description
Given k lists of sorted integers, find the smallest range [a, b] such that b - a is minimal and the range includes at least one number from each list.
Examples
Input:
nums = [[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]Output:
[20,24]Explanation:
Smallest range covering all lists.
Input:
nums = [[1]]Output:
[1]Explanation:
Minimal case with a single-element matrix.
Input:
nums = [[1,2,3],[1,2,3],[1,2,3]]Output:
[1,1]Explanation:
When all lists have identical elements, the smallest range is just picking the same element from each list. Picking 1 from each list gives range [1,1] with size 0, which is the minimum possible.
Constraints
- •
3 ≤ nums.length ≤ 3500