Non-overlapping Intervals
Recognize the pattern
Brute force idea
If you approach Non-overlapping Intervals in the most literal way possible, you get this: Try all subsets of non-overlapping intervals. Exponential. It is a fair place to begin because it matches the surface of the question, yet it does not capture the deeper structure that makes the problem simpler.
Better approach
The real unlock in Non-overlapping Intervals comes when you notice this: Sort by end time. Greedily keep intervals whose start ≥ previous end. Count removals = total - kept., after sorting once and scanning greedily. Instead of recomputing the world every time, you preserve just enough context to let the next decision become obvious.
Key invariant
The compass for Non-overlapping Intervals is this: Sorting by end time and always keeping the interval that ends earliest maximizes room for future intervals. An interval that ends later can only block more, never help. As long as that statement keeps holding, you can trust the steps built on top of it.
Watch out for
The trap in Non-overlapping Intervals usually looks like this: Sorting by start time instead of end time — start sorting doesn't guarantee optimal packing. End sorting is the classic activity selection insight. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.