Practice/Meta/Leetcode 1094. Car Pooling
CodingMust
You are building a meeting room booking system for a company. The company has a limited number of meeting rooms, and you need to determine whether all scheduled meetings can fit within the available room capacity.
You are given a list of meetings, where each meeting is represented as [startTime, endTime], indicating when the meeting begins and ends. You are also given roomCapacity, which represents the maximum number of meetings that can occur simultaneously.
Your task is to determine whether it's possible to schedule all meetings without exceeding the room capacity at any point in time. Return true if all meetings can be accommodated, otherwise return false.
Note that if one meeting ends at the exact time another begins (e.g., meeting A ends at time 5 and meeting B starts at time 5), they do not overlap and can use the same room.
true if all meetings can be scheduled within capacity, false otherwise0 <= meetings.length <= 1000meetings[i].length == 20 <= startTime < endTime <= 10^61 <= roomCapacity <= 1000Example 1:
Input: meetings = [[1, 3], [4, 6], [7, 9]], roomCapacity = 2 Output: true Explanation: The meetings don't overlap, so we only need 1 room at any time, which is within capacity.
Example 2:
Input: meetings = [[1, 5], [2, 6], [3, 7]], roomCapacity = 2 Output: false Explanation: At time 3, all three meetings are active simultaneously, requiring 3 rooms but only 2 are available.
Example 3:
Input: meetings = [[1, 3], [3, 5], [5, 7]], roomCapacity = 1 Output: true Explanation: Each meeting ends exactly when the next begins, so they can share the same room.