You are given a list of intervals, where each interval [l, r] includes every integer between l and r.
Your task is to build a set of numbers such that every interval contains at least two numbers from this set.
In other words, for each interval, there must be two distinct integers from your chosen set that fall inside the interval range.
Your goal is to determine the minimum number of integers needed in such a set.
Input: intervals = [[2,5],[4,9],[7,10]]
Output: 4
Explanation:
One valid smallest set is [4,5,9,10], which contributes at least two numbers to every interval.
Input: intervals = [[1,2],[2,6],[5,7]]
Output: 3
Explanation:
A valid minimum set is [2,5,6].
Input: intervals = [[3,4],[6,9],[8,10]]
Output: 4
Explanation:
A possible set is [3,4,8,9], covering all three intervals with two points each.
Accepted:
Submission: