Meeting Rooms III
Updated
Problem statement
A company has n conference rooms, labelled 0 through n - 1. Each entry meetings[i] = [start, end] is a booking request: the meeting wants to begin at time start and finish at time end, and the room it uses is free again at end. No two requests begin at the same time, and the list can be in any order.
Process the requests from the earliest start to the latest, using these rules:
- A room is free at time
tif the meeting it last held finishes attor before. - If some room is free when the meeting wants to begin, the meeting takes the free room with the smallest label.
- If every room is occupied, the meeting is pushed back. It takes the room that becomes free soonest (the smallest label if several become free at the same time) and begins the moment that room is free. Its length does not change, so it finishes
end - startafter its new start. - Pushed-back meetings get their rooms in the order of their original start times.
Return the room that hosted the largest number of meetings. If two or more rooms share that largest number, return the smallest room number among them.
Function
mostBooked(n: int, meetings: int[][]) → intExamples
Example 1
n = 2meetings = [[0,6],[2,4],[3,8],[5,7]]return = 0Take the meetings in order of start time.
[0, 6]: both rooms are free, so it goes to room 0, busy until 6.[2, 4]: room 1 is free, busy until 4.[3, 8]: no room is free at 3. Room 1 frees first, at 4, so the meeting waits and runs[4, 9]in room 1 (same length, 5).[5, 7]: no room is free at 5. Room 0 frees at 6 and room 1 at 9, so it runs[6, 8]in room 0.
Each room held 2 meetings. On a tie the smaller room number wins, so the answer is 0.
Example 2
n = 3meetings = [[0,5],[1,3],[2,4],[3,9],[4,6]]return = 1Rooms 0, 1 and 2 take the first three meetings and are busy until 5, 3 and 4. At time 3 room 1 is free again, so [3, 9] goes to room 1. At time 4 room 2 is free (room 1 is busy again), so [4, 6] goes to room 2.
Counts: room 0 has 1, room 1 has 2, room 2 has 2. Rooms 1 and 2 tie, so the answer is 1.
Example 3
n = 1meetings = [[5,10],[0,3]]return = 0With one room every meeting goes to room 0, so the answer is 0. The meetings are not given in time order; [0, 3] runs first.
Example 4
n = 2meetings = [[0,10],[1,2],[3,4],[5,6],[11,12]]return = 1[0, 10] keeps room 0 busy until 10. The short meetings at 1, 3 and 5 each find room 1 free and take it, because room 1 is the lowest-numbered free room. At 11 both rooms are free and [11, 12] takes room 0.
Room 0 held 2 meetings and room 1 held 3, so the answer is 1.
Constraints
1 <= n <= 1001 <= meetings.length <= 2000meetings[i].length == 20 <= meetings[i][0] < meetings[i][1] <= 100000- No two meetings start at the same time.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Shortest-Job-First Process SchedulingByteDance · PHONE SCREENByteDance interview questions
- Meeting Rooms III: Most Booked RoomGoogle · ONSITE INTERVIEWGoogle interview questions
- Cursor-Based Pagination Over Sorted LogsRoblox · ONSITE INTERVIEWRoblox interview questions
- Weighted Server Load Balancer with TTLStripe · ONSITE INTERVIEWStripe interview questions
- Document Indexer Scheduling MetricsGlean · PHONE SCREENGlean interview questions
- IPOTekion · PHONE SCREENTekion interview questions
- Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
- Four-Player Trick-Taking Card Game SimulationScale AI · OA · PHONE SCREENScale AI interview questions
- IPOInMobi · PHONE SCREENInMobi interview questions
- Popular and Instant-Runoff Election WinnersCoursera · PHONE SCREEN
Bloomberg LP interview experiences
- Bloomberg SWE Phone Screen and Onsite: 1 Experience
- Bloomberg SWE Phone Screens with Two Teams: 1 Experience
- Bloomberg AI Interview, Hiring Level Not Reported: 2 Experiences
- Bloomberg Experienced SWE AI Coding Interviews: 2 Experiences
- Bloomberg New Grad AI-Assisted Coding Rounds: 3 Experiences
- Bloomberg New Grad SWE AI-Assisted Coding Rounds: 1 Experience