632. Smallest Range Covering Elements from K Lists
632. Smallest Range Covering Elements from K Lists
Description
You have k lists of sorted integers in non-decreasingorder . Find the smallest range that includes at least one number from each of the k lists.
We define the range [a, b] is smaller than range [c, d] if b - a < d - c or a < c if b - a == d - c.
Example 1:
1 | Input: nums = [[4,10,15,24,26],[0,9,12,20],[5,18,22,30]] |
Example 2:
1 | Input: nums = [[1,2,3],[1,2,3],[1,2,3]] |
Constraints:
nums.length == k1 <= k <= 35001 <= nums[i].length <= 50-10^5 <= nums[i][j] <= 10^5nums[i]is sorted in non-decreasing order.
Hints/Notes
- 2025/02/05 Q2
- priority queue
- 0x3Fâs solution
Solution
Language: C++
1 | class Solution { |