Question bank › Intervals
Dsa Intervals Easy

Interval Gaps

Given a list of intervals [start, end], find the gaps between the end of one interval and the start of the next one, when the intervals are sorted by their starting times. A gap is defined as the difference between the end of one interval and the start of the next interval when the end is less than the start. Input format: - The first line contains an integer n (1 ≤ n ≤ 100): number of intervals. - The next n lines each contain two integers start and end, separated by a space (0 ≤ start < end ≤ 10^9). Output format: - Print the gaps in ascending order, each gap on a new line. If there are no gaps, print 'No Gaps'. Example: Input: 3 1 3 4 5 7 8 Output: 1 2

Key concepts

intervalsgapslist

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.