Question bank › Intervals
Dsa Intervals Easy

Redundant Server Monitoring

A system requires 'redundancy' to be considered safe. Redundancy is achieved at any point in time where at least two different servers are active. Given the activity intervals [start, end) of N servers, calculate the total duration of time that the system was 'safe' (i.e., at least 2 servers were active). Input Format: First line: N (number of servers). Next N lines: Two integers 'start' and 'end' (exclusive end). Output Format: A single integer representing the total 'safe' duration. Example: Input: 3 10 50 20 40 30 60 Output: 30 (From 20 to 30, servers 1 & 2 are active. From 30 to 40, all three. From 40 to 50, 1 & 3. Total safe time: 50 - 20 = 30.)

Key concepts

sweep lineinterval overlaps

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.