Dsa
Heap
Easy
Smallest Range Covering Elements from K Lists
You are given K sorted lists of integers. Your task is to find the smallest range that includes at least one number from each list.
Input format:
- The first line contains integer K (1 <= K <= 100).
- The following K lines each contain a sorted list of integers. Each list may have different lengths (at least 1 element). The integers are separated by spaces.
Output format:
- Output two integers representing the smallest range (inclusive) that contains at least one number from each list.
Example:
Input:
3
1 4 6
2 3 5
3 8 9
Output:
3 4
Key concepts
heapmergingrange
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now