Question bank › Intervals
Dsa Intervals Easy

Solo Shift Bonus

At a 24-hour facility, N shifts are scheduled. A worker earns a 'Concentration Bonus' for every minute they are the only person on duty. Given the start and end times of all shifts, calculate the total duration covered by exactly one shift. Input Format: - An integer N. - N lines, each containing S and E. Output Format: - A single integer representing the total 'solo' time. Example: Input: 2 1 10 5 15 Output: 9 Explanation: 1 to 5 (Solo), 5 to 10 (Overlap), 10 to 15 (Solo). Total = 4 + 5 = 9.

Key concepts

sweep-lineintervalsoverlap

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.