Feature #4: Schedule a New Meeting
Implementing the "Schedule a New Meeting" feature for our "Google Calendar" project.
We'll cover the following
Description
For this feature, we have a user who wants to add a new meeting to their tentative meeting schedule. First, we need to add the new meeting to the user’s schedule. Then, we want to make refinements in the schedule to merge some of the meetings. The user’s initial schedule will have no conflicts; however, the new meeting might overlap with one or more of the older ones. Therefore, we can save time by merging some of the meetings that can be held together in the same venue (this can be done for the tasks that can run simultaneously). The meetings can only be merged if the new meeting time overlaps or is adjacent to an existing meeting. We merge these meetings to eliminate conflict.
Suppose you are given a list of non-overlapping scheduled meetings, such as {{1, 3}, {4, 6}, {8, 10}, {10, 12}, {13, 15}, {16, 18}}
. The new meeting, which we need to fit into this already busy schedule, is also given; it is {9, 13}
. In this case, the new meeting overlaps with two meetings: {8, 10}
and {10, 12}
. After merging, the meeting is adjacent to the {13, 15}
meeting, so {13, 15}
will also be merged. Hence, the final schedule for the day will be: {{1, 3}, {4, 6}, {8, 15}, {16, 18}}
.
The illustration below shows a visual representation of the example.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.