Here is how we will implement this feature:
We will use two indices, i and j, to traverse both of the meeting schedules, meetingsA and meetingsB, respectively.
The indices i and j will both be zero at the beginning.
Next, we will check if meetingsA[i] and meetingsB[j] overlap by comparing the start and end times.
If the times overlap, the overlapping time interval will be added to the resultant list.
Otherwise, we will keep incrementing the indices depending upon the end time of the next meeting. This means that if the next meeting in meetingsA ends before the next meeting in meetingsB we will only increment i. This is because the current meeting in meetingsB has the possibility to overlap with the next meeting. Similarly, vice versa is also true in case of incrementation in j.
Scala