Solving Questions With Brainpower
specialist · 705 · lc medium +30 · verified · 60.2% accepted · 2,949 likes · top 59%
Description
You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].
The array describes an exam where you must consider each question in order and decide whether to solve it or skip it. Solving question i earns you pointsi points but forces you to skip the next brainpoweri questions. Skipping a question lets you proceed to the next one.
- For example, given questions = [[3, 2], [4, 3], [4, 4], [2, 5]]:
- Solving question 0 earns 3 points but you cannot attempt questions 1 or 2.
- Alternatively, skipping question 0 and solving question 1 earns 4 points but skips questions 2 and 3.
Return the maximum points you can earn on the exam.
Example 1:
Example 2:
Code