Dsa
Intervals
Hard
Counting Nested Intervals
You need to count how many intervals are nested within other intervals from a given set. An interval is defined as nested if it starts after the start and ends before the end of another interval. The input is provided as a space-separated string. Print the total count of nested intervals as an integer.
Example:
Input:
1 5 2 3 4 6 3 4
Output:
2
Key concepts
intervalsnestingcounting
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