GST Quarterly Filing Overlap
An Indian SaaS bookkeeping app shows a banner on every customer's dashboard the day their next GST quarterly filing window opens. Each tax-paying entity has its own filing window stored as an integer day-range [start_day, end_day]. The compliance team wants to know: on the busiest single day of the quarter, how many filings are simultaneously open?
Problem
Given a list of n intervals [start_i, end_i] representing filing windows (inclusive endpoints, integer day-of-year), return the maximum number of intervals that overlap at any single point.
Input
Integer n (0 ≤ n ≤ 10^5) and n pairs (start, end) with 1 ≤ start ≤ end ≤ 366.
Output
A single integer — the maximum simultaneous overlap.
Constraints
- 0 ≤ n ≤ 100,000
- 1 ≤ start ≤ end ≤ 366
- Endpoints are inclusive — an interval [1, 3] is active on days 1, 2, 3
Examples
Example 1
Input
intervals = [[1, 5], [3, 7], [6, 9]]
Output
2
Day 3: intervals 1 and 2 active (count 2). Day 6: intervals 2 and 3 active (count 2). Max = 2.
Example 2
Input
intervals = []
Output
0
No intervals → 0 overlap.