Dsa
Intervals
Medium
Interval Overlaps Count
You are given a list of intervals representing time slots. Your task is to count how many intervals overlap with any given interval. You should return a list of counts corresponding to each interval.
Input format: The first line contains an integer n (1 <= n <= 10^4), the number of intervals. The next n lines each contain two integers representing the start and end time of the intervals (0 <= start < end <= 24).
Output format: Print n lines where each line contains the count of overlapping intervals for the corresponding input interval.
Example:
Input:
3
1 5
2 6
3 4
Output:
2
2
1
Key concepts
intervalscountingbrute-force
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