Dsa
Intervals
Easy
Interval Uniqueness
Given a list of intervals, determine how many unique intervals exist after merging any overlapping intervals. An interval is represented by a start and an end time. You should print the number of unique intervals.
Input format:
- The first line contains an integer n, the number of intervals.
- Each of the following n lines contains two integers, start and end, separated by a space.
Output format:
- Print the total number of unique intervals as an integer.
Example:
Input:
4
1 3
2 4
5 8
6 7
Output:
2
Key concepts
intervalsuniquenesscounting
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