Question bank › Intervals
Dsa Intervals Easy

Smart Highway Paving

A construction crew is paving segments of a highway. Because of logistics, some segments they pave overlap. Given a list of [start, end] coordinates representing paved segments, calculate the total unique length of the highway that has been paved. Input Format: First line: Integer N (number of segments). Next N lines: Two integers 'start' and 'end' per line. Output Format: A single integer representing the total length covered. Example: Input: 3 10 20 15 25 30 40 Output: 25 (Merged intervals are [10, 25] length 15, and [30, 40] length 10. Total = 25.)

Key concepts

merging intervalstotal coverage

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.