[00:01] Turns out, companies love asking problems about exactly this. Here are every interval coding question. An interval is just a start time and an end A problem hands you a list of these, totally unsorted. Every interval problem [00:14] first, then walk through in order. There are two sorting strategies, and which one you pick depends on the problem. Strategy one, sort by start time. This Now, overlaps sit right next to each other. To detect an overlap, check one [00:27] previous one ends? If next start is less than previous end, they overlap. That's how you check if any intervals overlap. Sort by start, combining overlapping intervals into one? Same sort, but instead of just [00:39] When two intervals overlap, extend the merged end to cover both. Take the max of both ends. So, 1 to 3 and 2 to 6 become 1 to 6. merging as you go. That's how you merge all overlapping intervals. [00:53] What if you want the most non-overlapping intervals? meetings in a day. Sort by start time fails here. earliest, but it runs all day long. It blocks everything else. You fit one [01:06] meeting instead of three. The fix? Sort by end time instead. Always pick the leaves the most room for whatever comes next. Greedy choice, always optimal. Sort by start gave you one meeting. Sort by end, three. Two strategies, that's [01:18] all there is to it. Sort by start for detecting overlaps and merging. non-overlapping count. Try these problems on Hello Interview. Link is in problems on Hello Interview. Link is in the pinned comment. Follow for more.