FastPrepMinimum Meeting Rooms
Problem · Array

Minimum Meeting Rooms

Learn this problem
MediumJPMorgan Chase logoJPMorgan ChaseNEW GRADINTERNOA

Problem statement

You are given a list of n meetings. Each meetingTimings[i] = [start, end] contains the start time and end time of one meeting.

Assign every meeting to a room under these rules:

  • No two overlapping meetings may use the same room.
  • A meeting that ends at time t and another meeting that starts at time t do not overlap and may use the same room.
  • A zero-duration meeting [t, t] still receives a room assignment, but it does not overlap any meeting. Zero-duration meetings may reuse the same room.

Return the minimum number of rooms needed to schedule all meetings.

Function

minMeetingRooms(meetingTimings: int[][]) → int

Examples

Example 1

meetingTimings = [[1,4],[1,5],[5,6],[6,10],[7,9]]return = 2

The meetings [1,4] and [1,5] overlap, so at least two rooms are required. Two rooms are sufficient because a meeting ending at time t can share a room with one starting at time t. The meetings [6,10] and [7,9] also occupy the two rooms concurrently.

Example 2

meetingTimings = [[1,2],[2,3],[3,4]]return = 1

Each meeting starts exactly when the preceding meeting ends, so one room can host all three meetings.

Constraints

  • 1 <= meetingTimings.length <= 2 * 10^5
  • meetingTimings[i].length == 2
  • 1 <= meetingTimings[i][0] <= meetingTimings[i][1] <= 2 * 10^6

More JPMorgan Chase problems

drafts saved locally
public int minMeetingRooms(int[][] meetingTimings) {
  // Write your code here.
}
meetingTimings[[1,4],[1,5],[5,6],[6,10],[7,9]]
expected2
checking account