Solving Questions With Brainpower

You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].

The array describes the questions of an exam, where you have to process the questions in order (from the first to the last question). For each question i, you can either:

  • Solve it and earn pointsi points — but you will be unable to solve the next brainpoweri questions (i.e., the next brainpoweri questions are skipped).
  • Skip it and proceed to the next question.

Return the maximum points you can earn for the exam.

Examples
Input: [[3,2],[4,3],[4,4],[2,5]]
Output: 5
Hints
Related Problems

Solving Questions With Brainpower

You are given a 0-indexed 2D integer array `questions` where `questions[i] = [pointsi, brainpoweri]`.