Maximum Number of Events That Can Be Attended II
Given an array of events where events[i] = [startDay, endDay, value], and an integer k. You can attend at most k events. You cannot attend two events that overlap. Return the maximum sum of values that you can receive by attending events.

30:00

Maximum Number of Events That Can Be Attended II
hard
Topics
Companies

Given an array of events where events[i] = [startDay, endDay, value], and an integer k. You can attend at most k events. You cannot attend two events that overlap. Return the maximum sum of values that you can receive by attending events.

Example 1:
Input: {"events":[[1,2,4],[3,4,3],[2,3,1]],"k":2}
Output: 7
Constraints:
  • 1kevents.length1 \leq k \leq \text{events.length}

  • 1kevents.length1061 \leq k \cdot \text{events.length} \leq 10^6

  • 1startDayiendDayi1091 \leq \text{startDay}_i \leq \text{endDay}_i \leq 10^9

  • 1valuei1061 \leq \text{value}_i \leq 10^6

Input
arr ={"events":[[1,2,4],[3,4,3],[2,3,1]],"k":2}

Events: 3, k=2

Events Timeline (k=2)

1

2

3

4

5

[1,2] v=4

[3,4] v=3

[2,3] v=1

Remaining slots: 2

Maximum Value:

?

Current

Selected

Variables
No variables to display
DepthFunction Call
Stack empty
0/1