Create a meeting manager that has the following functionalities. Given a list of meeting times, check if any of them overlap. Return the minimum number of rooms required to accommodate all the meetings.
class MeetingsManager {
public addMeeting(startTime: number, endTime: number): void {}
public hasOverlappingTimes(): boolean {
return false;
}
public minMeetingRooms(): number {
return -1;
}
}Suppose we use interval (start, end) to denote the start and end time of the meeting, we have the following meeting times: (1,4), (4,5), (6,8), (2,6)
In the above example, we should return true for the first question since (1, 4) and (2, 6) have overlaps. The minimum number of rooms for the example is 2.
const meetingsManager = new MeetingsManager();
meetingsManager.addMeeting(1, 4);
meetingsManager.addMeeting(4, 5);
meetingsManager.addMeeting(6, 8);
meetingsManager.addMeeting(2, 6);
console.log('Do any of the meetings overlap? ' + meetingsManager.hasOverlappingTimes());
console.log('Minimum number of rooms required: ' + meetingsManager.minMeetingRooms());
// Output should be:
// Do any of the meetings overlap? true
// Minimum number of rooms required: 2