Question bank › Intervals
Dsa Intervals Easy

Interval Intersection

Given two lists of intervals, find the intersection of intervals from the two lists. An intersection occurs if two intervals overlap, returning intervals that are common in both inputs. Each interval is input as two integers separated by space. Input format: - The first line contains an integer n (1 ≤ n ≤ 100) representing the number of intervals in the first list. - Each of the next n lines contains two space-separated integers a and b (0 ≤ a < b ≤ 24) for the first list. - The following line contains an integer m (1 ≤ m ≤ 100) representing the number of intervals in the second list. - Each of the next m lines contains two space-separated integers c and d (0 ≤ c < d ≤ 24) for the second list. Output format: - The output should be a list of intersecting intervals, where each interval is presented as two space-separated integers. Example: Input: 3 1 3 2 4 5 7 2 2 5 6 8 Output: 2 3

Key concepts

intervalsintersectionrange

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.