Solution
To solve this problem, it is best to sort the meetings based on the startTime. Then, we can determine if two meetings should be merged or not by processing them simultaneously.
Here is how we’ll implement this feature:
First, we will sort the meetings according to startTime.
Considering two meetings at a time, we will then check if the startTime of the second meeting is less than the endTime of the first meeting.
If the condition is true, merge the meetings into a new meeting and delete the existing ones.
Repeat the above steps until all the meetings are processed.