← Practice problem bank

Jan 1, 2026

Meeting Room Scheduler

Daily Challenge Archive · Open

mediumsorting

150 pts · 10000 ms · 128 MB · Practice only

Problem

Imagine you are an event coordinator at a bustling convention center, responsible for scheduling meetings in a single, highly demanded conference room. You have a list of meetings, each defined by a start time and an end time. Your task is to organize these meetings in a manner that maximizes the number of meetings held without any overlap, meaning no two meetings can occur simultaneously. A meeting [s1, e1] does not overlap with another meeting [s2, e2] if one ends before or when the other starts (e1 <= s2 or e2 <= s1). To tackle this problem, follow these steps: 1. Analyze the list of meetings and their respective start and end times. 2. Determine a strategy to select the maximum number of non-overlapping meetings. 3. Implement an algorithm, possibly using a greedy approach, to schedule these meetings optimally. Consider an example where you have meetings: [1, 3], [2, 4], [3, 5]. The optimal solution would be to schedule meetings [1, 3] and [3, 5], allowing two meetings to be held. Remember, edge cases such as meetings with the same start and end times or overlapping time slots need careful consideration.

Hints
Think about using a greedy algorithm to make the optimal choice at each step. Sorting the meetings by their end times might be useful. Consider edge cases like meetings that start and end at the same time. Efficiency can be improved by focusing on the earliest end times first, minimizing room idle time and maximizing the number of meetings scheduled.

Input format

The first line contains an integer n (1 <= n <= 1000), the number of meetings. Each of the next n lines contains two integers s and e (0 <= s < e <= 10000), representing the start and end times of a meeting.

Output format

A single integer representing the maximum number of non-overlapping meetings that can be scheduled.

Constraints

1 <= n <= 1000, 0 <= s < e <= 10000

Sample input

3
1 3
2 4
3 5

Sample output

2

Sign in to submit solutions

Run your code against all test cases and get instant feedback.

Sign in