Divide Intervals Into Minimum Number of Groups
MediumIntervals
Decode it first. Clues, constraints, pattern and plan before any code.intervals[i] = [left, right] is an inclusive interval. Divide all of them into groups so that no two intervals in the same group intersect. Two intervals intersect if they share at least one number, so [1, 5] and [5, 8] intersect. Return the minimum number of groups.
[[5, 10], [6, 8], [1, 5], [2, 3], [1, 10]] → 3
[[1, 3], [5, 6], [8, 10], [11, 13]] → 1Constraints
1 <= intervals.length <= 10^51 <= left <= right <= 10^6