मुख्य कंटेंट तक स्किप करें
Back to ChallengesMaximum Number of MeetingsEasy 15 min

Maximum Number of Meetings

You are given the start and end times of N meetings in the form of arrays start[] and end[]. Find the maximum number of meetings that can be accommodated in a single meeting room.

Examples

Input: start = [1, 3, 0, 5, 8, 5], end = [2, 4, 6, 7, 9, 9]
Output: 4
Maximum 4 meetings can be accommodated: [1,2], [3,4], [5,7], and [8,9].

Constraints

  • 1 <= N <= 10^5
  • 0 <= start[i] < end[i] <= 10^5

Complexity Analysis

Time
O(N log N)
due to sorting.
Space
O(N)
to store the combined meeting objects.

Test Cases

#1 Standard case
Input: start = [1,3,0,5,8,5], end = [2,4,6,7,9,9]
Expected: 4
#2 No overlapping meetings
Input: start = [10,12,20], end = [20,25,30]
Expected: 2
Output
Click "Run Code" to see output here...