Dsa
Intervals
Easy
The Crowded Buffet
In a luxury hotel, N guests arrive and leave the buffet at specific times. Each guest 'i' is present during the interval [start_i, end_i). This means they are present at start_i but have left exactly by end_i. The hotel manager wants to know the maximum number of guests present at the same time to ensure enough seating.
Input Format: The first line contains N. The next N lines each contain two integers, start and end.
Output Format: Print a single integer representing the maximum overlap.
Example:
Input:
3
10 20
15 25
20 30
Output:
2
Key concepts
sweep-linesorting
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