A Nested Paint Span Understates Mural Coverage
Level 2 · node · Correctness · Union length of overlapping paint spans
Scenario
A fictional mural studio records painted spans for each wall and reports the length actually covered. Overlaps must not count twice, but a wall with a short span wholly inside a longer one is reported as shorter than it is.
Requirements
Compute the total length of the union of [start, end) spans on each wall. The spans are valid and can arrive in any order.
Acceptance criteria
- Add the lengths of disjoint spans.
- Preserve coverage when one span is wholly inside another.
- Count a chain of overlapping spans only once.
- Return zero when there are no spans.