FastPrepMeeting Room Scheduler
Problems/Meeting Room Scheduler

Meeting Room Scheduler

Amazon logoAmazon● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source explicitly requests an implemented meeting-room scheduler but omits its operations, allocation rule, conflict result, and interval convention. The judged version processes chronological requests and assigns the lowest available room, so the core task match is about 78%.

Implement a scheduler for roomCount meeting rooms numbered from 0 to roomCount - 1.

Each row meetings[i] = [start, end] is a request for the half-open interval [start, end). Requests appear in nondecreasing start order and are processed in input order. Assign the lowest-numbered available room. If every room overlaps the request, reject it with -1.

Return an array whose ith value is the assigned room number or -1. A rejected request does not reserve a room.

Function

scheduleMeetings(roomCount: int, meetings: int[][]) → int[]

Examples

Example 1

roomCount = 2meetings = [[0,10],[5,7],[10,12],[10,15]]return = [0,1,0,1]

The first two requests occupy rooms 0 and 1. At time 10, both are free; input order gives the third request room 0 and the fourth room 1.

Example 2

roomCount = 1meetings = [[1,4],[2,3],[4,5]]return = [0,-1,0]

The second request conflicts with [1,4). The room is available again exactly at time 4.

Example 3

roomCount = 2meetings = [[1,2],[1,2],[1,2]]return = [0,1,-1]

Two simultaneous requests take both rooms, so the third request is rejected.

Constraints

  • 1 <= roomCount <= 10^5.
  • 1 <= meetings.length <= 10^5.
  • meetings[i].length == 2.
  • 0 <= start < end <= 10^9.
  • Meeting start times are nondecreasing.

More Amazon problems

  • Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
See Amazon hiring insights
Saved
class Solution {
    public int[] scheduleMeetings(int roomCount, int[][] meetings) {
      // write your code here
    }
}
Checking account…