Question bank › Intervals
Dsa Intervals Easy

The Continuous Connection

A telecommunications company is laying down fiber optic cables in segments. Each segment covers the range [start, end]. Some segments overlap or touch, forming a single continuous cable. Find the length of the longest continuous cable formed by the union of these segments. Input Format: The first line contains N. The next N lines contain the start and end of each segment. Output Format: A single integer representing the maximum length of a merged segment. Example: Input: 4 0 10 10 20 30 45 40 55 Output: 25 (Merged segments are [0, 20] length 20, and [30, 55] length 25.)

Key concepts

mergingunion

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.