Skip to main content
Back to problems
Leetcode
Medium
Heaps
Ordered Structures
Arrays
Google
Amazon
Microsoft
Meeting Rooms III

Schedule meetings across rooms and report which room hosts the most meetings when rooms become available at different times.

Acceptance 100%
Problem Statement

Meeting Rooms III

You are given a set of meeting requests, each with a start time and an end time. There are n meeting rooms labeled from 0 to n - 1.

A meeting is assigned to the smallest-index room that is free at its scheduled start time. If no room is free, the meeting is delayed until the earliest room becomes available, and it keeps the same duration.

After all meetings are processed, return the index of the room that hosted the most meetings. If multiple rooms hosted the same maximum number, return the smallest index among them.

Input Format

  • n: number of meeting rooms
  • meetings: array of [start, end] pairs

Output Format

  • Return the index of the room that hosted the most meetings.

Constraints

  • 1 <= n
  • meetings.length >= 1
  • Each meeting has start < end
  • Meeting times are integers and can be processed in chronological order

Hints

  • Sort meetings by start time.
  • Track free rooms by smallest index.
  • Track occupied rooms by earliest finishing time, and free rooms when their meetings end.
  • When a meeting is delayed, preserve its duration.

Input Format

  • An integer n.
  • A list of meeting intervals meetings, where each interval is [start, end].

Output Format

  • Return a single integer: the room index with the highest meeting count, breaking ties by smaller index.

Constraints

  • Assign each meeting to the lowest-index available room.
  • If no room is available, delay the meeting to the earliest time a room frees up.
  • Preserve meeting duration when delayed.
Examples
Sample cases returned by the problem API.

Example 1

Input

n = 2
meetings = [[0,10],[1,5],[2,7],[3,4]]

Output

0

Explanation

Room 0 takes the first meeting. Room 1 takes the second. The third meeting is delayed until room 1 frees up, and the fourth meeting is also delayed. In the end, room 0 hosts more meetings than room 1.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.