How do you burst the fewest balloons (or shoot the fewest arrows) so every interval is hit?
PICTURE THIS: HOW TO EXPLAIN IT
Simple meaning
Sort intervals by end and shoot at the current end
WHY — Greedy instead of guessing?
Why interviewers care about Greedy:
question about Greedy.
trade-offs, and what you would actually do on a DSA project - not buzzwords.
Name the idea, why it exists, then one short example.
End with when you use it and one common pitfall.
STEPS — What happens step by step?
Before you speak the answer, walk the interviewer through these steps:
- 1Sort intervals by end
and shoot at the current end
- 2skip later intervals that
start at or before that point, otherwise spend a new arrow.
- 3Sorting O(n log n),
scan O(n).
- 4This is the same
greedy as activity selection on finish time.
- 5Common mistake
What juniors usually get wrong.
- 6Close
When you pick this over the alternative.
EXAMPLE — See it in action
Here's a short line you can speak, broken into clear beats:
Note: Adapt this scaffold to your own project — keep it under 60–90 seconds.
Key takeaway
Sort intervals by end and shoot at the current end skip later intervals that start at or before that point, otherwise spend a new arrow.