13. Smallest range in K lists
Input:
N = 5, K = 3
KSortedArray[][] = {{1 3 5 7 9},
{0 2 4 6 8},
{2 3 5 7 11}}
Output: 1 2
Explanation: K = 3
A:[1 3 5 7 9]
B:[0 2 4 6 8]
C:[2 3 5 7 11]
Smallest range is formed by number 1
present in first list and 2 is present
in both 2nd and 3rd list.Input:
N = 4, K = 3
KSortedArray[][] = {{1 2 3 4},
{5 6 7 8},
{9 10 11 12}}
Output: 4 9Solution:
Solution: (Heap)
Last updated