Non-overlapping Intervals
Signals to notice
Brute force first
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.
The key insight
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.
What must stay true
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.
Easy way to go wrong
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.