Minimum Number of Platforms
Recognize the pattern
Brute force idea
If you approach Minimum Number of Platforms in the most literal way possible, you get this: For each train, count how many others overlap. 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 deeper shift in Minimum Number of Platforms is this: Sort arrivals and departures separately. Two pointers: if next event is arrival, +1 platform. If departure, -1 platform. Track the peak. Once you hold onto the right piece of information from moment to moment, the problem feels less like trial and error and more like following a shape that was there all along.
Key invariant
At the center of Minimum Number of Platforms is one steady idea: The minimum platforms = maximum number of simultaneously present trains. The event sweep counts active trains at every transition point. When you keep that truth intact, each local choice supports the larger solution instead of fighting it.
Watch out for
A common way to get lost in Minimum Number of Platforms is this: Processing arrivals and departures together without sorting them separately — sorting by event time (treating arrivals and departures as events on a timeline) gives the correct chronological order. Most mistakes here are not about syntax; they come from losing track of what your state, pointer, or structure is supposed to mean.