Question bank › Intervals
Dsa Intervals Easy

Universal API Compatibility

You are developing a plugin that must be compatible with multiple software versions. Each dependency 'i' specifies a range [min_v, max_v] of versions it supports. To be compatible with all dependencies, your plugin must use a version that falls within every dependency's range. Find the total number of versions that are compatible with all N dependencies. Input Format: First line: N (number of dependencies). Next N lines: Two integers 'min_v' and 'max_v' (inclusive). Output Format: An integer representing the count of compatible versions (0 if no version works). Example: Input: 2 10 20 15 25 Output: 6 (The intersection is [15, 20], which includes versions 15, 16, 17, 18, 19, 20.)

Key concepts

intersectioninterval constraints

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.