Practice · 2 of 6
Clinic: The Interval Illusion
CHALLENGE
Difficulty: advanced+25 XP
**Bài toán.** Choose the maximum number of pairwise non-overlapping
intervals. Overlap at a shared endpoint is allowed only if one ends exactly
where the other starts? NO — shared endpoints count as overlap here: [1,3]
and [3,5] DO overlap. n ≤ 200000.
**The submission below sorts by start and takes greedily — Wrong Answer.**
Produce the counterexample, name the class, fix it.
``cpp
sort by start;
take interval if start >= lastEnd;
``
Press Submit to check your solution.
Back to lesson: Practice: Clinic Set 1 — Six Classic Bugs