Search⌘ K
AI Features

Solution: Maximum Number of Events That Can Be Attended II

C# solution for the Maximum Number of Events That Can Be Attended II problem using the Dynamic Programming pattern.

Statement

You are given an array events, where each element is a list [startDay_i, endDay_i, value_i] describing an event that starts on day startDay_i, ends on day endDay_i, and provides a value of value_i if you attend it.

You may attend at most k events. Attending an event requires you to be available for every day from startDay_i through endDay_i inclusive, so you cannot attend two events whose date ranges overlap.

Return the maximum total value you can obtain by attending at most k non overlapping events.

Note: You are not required to attend exactly k events.

Constraints:

  • 11 \leq k \leq events.length

  • 11 \leq k \cdot events.length 106\leq 10^6

  • ...