Practice · 2 of 5
Busiest Hour
CHALLENGE
Difficulty: beginner+25 XP
**Description:** A cafe has n chairs and q visitors; visitor i occupies the time
interval [l_i, r_i] (inclusive, in minutes). What is the maximum number of visitors
present at the same minute?
**Input:** Line 1: n q (1 <= n <= 10^6, 1 <= q <= 2*10^5). Next q lines: l r
(1 <= l <= r <= n).
**Output:** One integer — the maximum concurrent visitors.
**Example:** 10 2 / 1 3 / 2 5 -> 2 (minute 2 or 3).
Press Submit to check your solution.
Back to lesson: Practice: Difference Array Problem Set