#K64877. Minimum Meeting Rooms

    ID: 32073 Type: Default 1000ms 256MiB

Minimum Meeting Rooms

Minimum Meeting Rooms

You are given n meetings with their starting and ending times. Your task is to determine the minimum number of meeting rooms required so that all meetings can be hosted without any overlaps.

Formally, if the ith meeting starts at time \(s_i\) and ends at time \(e_i\), a room can be reused for meeting \(j\) only if \(s_j \geq e_i\). The goal is to compute the minimum number of rooms required.

Input Constraints:

  • \(1 \leq n \leq 10^5\)
  • \(0 \leq s_i < e_i \leq 10^9\)

inputFormat

The first line contains an integer n representing the number of meetings. The following n lines each contain two space-separated integers representing the starting time and ending time of a meeting.

Example:

3
0 10
5 20
15 30

outputFormat

Output a single integer representing the minimum number of meeting rooms required to host all the meetings.

Example:

2
## sample
1
0 10
1