Greedy Algorithms8 sections · 316 units
Open in Course

Meeting Rooms - Algorithm

Overlap detection

Sort meetings by start time. Then scan through and check if any meeting starts before the previous one ends. If meeting[i].start<meeting[i1].endmeeting[i].start < meeting[i-1].end, there is an overlap. You cannot attend both.

This is the simplest interval overlap check: sort, then linear scan comparing adjacent pairs. No need for complex data structures. Time: O(nlogn)O(n \log n). Space: O(1)O(1) extra. Common bug: using <= instead of < when meetings can touch without conflicting.