Dsa
Intervals
Easy
Interval Overlap Count
You are given a list of intervals and need to find out how many intervals overlap with a given target interval. An overlap occurs if two intervals share at least one common point. Each interval is input as two integers separated by space. The target interval is also given as input.
Input format:
- The first line contains a single integer n (1 ≤ n ≤ 100) representing the number of intervals.
- Each of the next n lines contains two space-separated integers a and b (0 ≤ a < b ≤ 24) representing an interval [a, b).
- The last line contains two space-separated integers c and d (the target interval).
Output format:
- A single integer representing the count of overlapping intervals.
Example:
Input:
3
1 3
2 5
6 8
2 4
Output:
2
Key concepts
intervalscountingoverlap
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