Skip to content

Practice Solving Questions With Brainpower

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2140
LeetCode Problem

Solving Questions With Brainpower

Problem Statement

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 (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve each of the next brainpoweri questions. If you skip question i, you get to make the decision on the next question. Return the maximum points you can earn for the exam.

Source: Solving Questions With Brainpower on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
questions = [[3,2],[4,3],[4,4],[2,5]]
Output
5

# Example 2

Input
questions = [[1,1],[2,2],[3,3],[4,4],[5,5]]
Output
7

Constraints

1 <= questions.length <= 10^5
questions[i].length == 2
1 <= pointsi, brainpoweri <= 10^5

Related LeetCode Problems

Practice more problems similar to Solving Questions With Brainpower.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.