6
def smallestRange(self, nums: List[List[int]]) -> List[int]:7
heap = [(row[0], i, 0) for i, row in enumerate(nums)]9
ans = [-(10**9), 10**9]10
right = max(row[0] for row in nums)12
left, row, col = heapq.heappop(heap)13
if right - left < ans[1] - ans[0]:15
if col + 1 == len(nums[row]):17
right = max(right, nums[row][col + 1])18
heapq.heappush(heap, (nums[row][col + 1], row, col + 1))22
if __name__ == "__main__":25
output1 = s.smallestRange([[4, 10, 15, 24, 26], [0, 9, 12, 20], [5, 18, 22, 30]])26
expected_output1 = [20, 24]28
output1 == expected_output129
), f"Expected {expected_output1}, but got {output1}"31
output2 = s.smallestRange([[1, 2, 3], [1, 2, 3], [1, 2, 3]])32
expected_output2 = [1, 1]34
output2 == expected_output235
), f"Expected {expected_output2}, but got {output2}"36
print("All tests passed!")