Comment by AlotOfReading
Comment by AlotOfReading 17 hours ago
This is one of those cases where being able to name the problem helps. It's a discrete interval problem and is typically solved by a discrete interval tree.
Diets are a particularly clever solution to this:
That’s the same idea as putting intervals in map, an ordered tree.