Question bank › Intervals
Dsa Intervals Easy

The Server Overload

A server is considered 'Overloaded' during any time period where it is handling at least K requests simultaneously. Given N request intervals [start, end), calculate the total duration (in minutes) that the server spent in an Overloaded state. Input Format: The first line contains K and N. The next N lines contain start and end times for each request. Output Format: A single integer representing the total duration. Example: Input: 2 3 10 20 15 25 20 30 Output: 10 (Overloaded when count >= 2: [15, 20] and [20, 25]. Total = 10.)

Key concepts

sweep-lineinterval-duration

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.