Loading...
You are given an array intervals, where intervals[i] = [start, end, reward] occupies the inclusive day range start to end and pays reward if selected.
Select intervals so that no two selected intervals share a day (after one ends on day d, the next may start no earlier than day d + 1) and the total reward is maximized.
Return the maximum total reward.
Input: intervals = [[2,4,4],[3,6,6],[6,8,2],[5,7,3]]
Output: 7
Explanation: Select [2,4,4] and [5,7,3] for 4 + 3 = 7. The 6-reward interval blocks days 3-6, leaving at most 6 + nothing compatible except [6,8,2]... which shares day 6, so 7 is optimal.
Input: intervals = [[1,3,5],[3,5,5]]
Output: 5
Explanation: Both intervals use day 3, so only one can be selected.
intervals.length ≤2⋅105intervals[i].length =3start ≤ end ≤109reward ≤109Click "Run" to test with sample cases or "Submit" to run all tests.