Smallest Range Covering Elements from K Lists

You have k lists of sorted integers in non-decreasing order. Your task is to find the smallest range that includes at least one number from each of the k lists. The range [a, b] is considered smaller than [c, d] if b - a is less than d - c, or if b - a is equal to d - c and a is less than c.

Constraints

  • nums.length == k
  • 1 <= k <= 3500
  • 1 <= nums[i].length <= 50
  • -10^5 <= nums[i][j] <= 10^5
  • nums[i] is sorted in non-decreasing order.
Saving… · 3 lines
class Solution:
def smallestRangeCoveringElementsFromKLists(self, nums: List[List[int]]) -> List[int]:

Console

Click Run to execute sample tests.