You are given a 2D integer array meetings, where meetings[i] = [starti, endi, revenuei] represents a meeting starting at time starti, ending at time endi, with revenue revenuei.
All meetings use half-open intervals [start, end), so meetings that only touch at endpoints do not overlap.
You may select any non-empty subset of meetings such that no two selected meetings overlap. You earn the revenue of each selected meeting.
Arrange the selected meetings in increasing order of their start times. For each pair of adjacent meetings in this order, you also earn 1 unit of revenue per unit of idle time between them. This idle time equals the later meeting's start time minus the earlier meeting's end time.
No idle revenue is earned before the earliest selected meeting starts or after the latest selected meeting ends. If only one meeting is selected, no idle revenue is earned.
Return the maximum total earnings achievable.
A subset of an array is a selection of elements of the array.
Example 1:
Input: meetings = [[2,5,4],[6,8,3]]
Output: 8
Explanation:
4 + 3 = 7 units of meeting revenue.6 - 5 = 1 additional unit.7 + 1 = 8.Example 2:
Input: meetings = [[3,5,4],[4,7,8],[8,10,3]]
Output: 12
Explanation:
8 + 3 = 11 units of meeting revenue.8 - 7 = 1 additional unit.11 + 1 = 12.Example 3:
Input: meetings = [[1,2,2],[4,5,2],[7,9,3]]
Output: 11
Explanation:
2 + 2 + 3 = 7 units of meeting revenue.4 - 2 = 2 additional units.7 - 5 = 2 additional units.7 + 2 + 2 = 11.1 <= meetings.length <= 105meetings[i] = [starti, endi, revenuei]0 <= starti < endi <= 1091 <= revenuei <= 109Loading editor...
[[2,5,4],[6,8,3]]