Dsa
Prefix Sum
Easy
Hotel Peak Occupancy
A boutique hotel tracks guest stays by day numbers (1 to 1,000,000). Given a list of N guest bookings, each with a start and end day [S, E] (inclusive), find the maximum number of guests staying at the hotel on any single day.
Example:
Input:
3
1 5
2 4
5 6
Output:
2
Explanation:
Day 1: 1 guest. Days 2-4: 2 guests. Day 5: 2 guests. Day 6: 1 guest. Max is 2.
Key concepts
difference_arrayprefix_sum
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