Dsa
Intervals
Hard
Gaps Between Scheduled Intervals
You are tasked with finding the total gaps between a list of scheduled intervals. Each interval is defined by its start and end times. The input is provided as a space-separated string. Print the total length of gaps as an integer, where a gap is defined as any time not covered by the intervals.
Example:
Input:
1 5 6 10 12 15
Output:
4
Key concepts
intervalsgapsscheduling
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