Intervals
Ranges with a start and end — overlap tests, merging, and counting how many run at once.
This topic is part of Pro.
Free covers the C and Python courses, the first three DSA topics, the opening system design lessons and the beginner AI lessons, all with the full coach. Pro opens the rest of the library in the FollowtheDamnCode app.
What is in it
- 1Overlap, and why sorting helpsTwo intervals overlap when each starts before the other ends; after sorting, only neighbours can clash. Pro
- 2Merging intervalsSort by start, then either extend the last merged interval or start a new one. Pro
- 3Counting overlaps with a sweep lineTurn intervals into +1/−1 events, sort them, and track how many are active — or keep a heap of end times. Pro