Mark As Completed Discussion

One Pager Cheat Sheet

  • We can write a method that merges any overlapping meetings in a given array of time intervals with a time complexity of O(n) and a space complexity of O(n).
  • Merging time ranges is relatively straightforward, as long as the intervals are properly sorted; we just need to take the smallest beginning/start time, and follow the chronological order to find the largest end/finishing time.
  • We iterate through the sorted array of intervals, comparing the last interval and referencing a result list to store modified intervals from clear separations or overlaps.

This is our final solution.

To visualize the solution and step through the below code, click Visualize the Solution on the right-side menu or the VISUALIZE button in Interactive Mode.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

You're doing a wonderful job. Keep going!

If you had any problems with this tutorial, check out the main forum thread here.