VOOZH about

URL: https://www.geeksforgeeks.org/dsa/find-maximum-meetings-in-one-room/

⇱ Maximum Meetings in One Room - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Maximum Meetings in One Room

Last Updated : 3 May, 2026

Given n meetings in the form of start[] and end[], where start[i] is the start time of ith meeting and end[i] is the end time of ith meeting. The task is to find the maximum number of meetings that can be scheduled in a single room. The meeting room can have only one meeting at a particular time.

Note: The start time of one chosen meeting can't be equal to the end time of any other chosen meeting.

Examples:

Input: start[] = [1, 3, 0, 5, 8, 5], end[] = [2, 4, 6, 7, 9, 9] 
Output: 1 2 4 5
Explanation: We can attend the 1st meeting from (1 to 2), then the 2nd meeting from (3 to 4), then the 4th meeting from (5 to 7), and the 5th meeting from (8 to 9).

Input: start[] = [10, 12, 20], end[] = [20, 25, 30]
Output: 1
Explanation: We can attend at most one meeting in a single meeting room.

Using Greedy Scheduling - O(n log n) Time and O(n) Space

The idea is to select the maximum number of non-overlapping meetings using a greedy strategy.

  • We always pick the meeting that finishes earliest so that we get more room to schedule remaining meetings.
  • By sorting meetings based on their finish time, we ensure that at each step we choose the best possible meeting that leaves maximum time for others.

Steps

  • Store meetings as (finish time, index) pairs and sort meetings based on finish time
  • Pick the first meeting (earliest finish). Set lastFinish = finish time of first meeting
  • Traverse remaining meetings: If start > lastFinish, select meeting and Update lastFinish
  • Store selected meeting indices and sort indices before returning

Below is the implementation of the above approach.


Output
1 2 4 5 
Comment
Article Tags:
Article Tags: