mediumIntervalsIndian domain~22 min
UPI Mandate Interval Conflict
A UPI autopay system registers recurring e-mandates, each active over a [start, end] day range. Two mandates on the same account must never have overlapping active windows. Given an account's mandates, detect whether any two overlap.
Problem
Given a list of intervals [start, end] (inclusive), return true if any two intervals overlap, and false if they are all pairwise disjoint.
Input
An array intervals of length n (0 ≤ n ≤ 10^5), each [start, end] with start ≤ end, values in [0, 10^9].
Output
A boolean — true if any two intervals overlap.
Constraints
- 0 ≤ n ≤ 100,000
- Each interval has start ≤ end and is inclusive
- Touching at a shared endpoint counts as overlap
Examples
Example 1
Input
intervals = [[1, 3], [2, 4]]
Output
true
[1,3] and [2,4] share days 2 and 3.
Example 2
Input
intervals = [[1, 2], [3, 4]]
Output
false
The windows are disjoint with a gap between day 2 and day 3.