Solving Questions With Brainpower

Medium

Description

Given exam questions with points and brainpower (skip count after solving), maximize points by choosing which questions to solve.

Examples

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

Solve q0 + q3.

Input:questions = [[1]]
Output:1
Explanation:

Minimal case with a single question.

Input:questions = [[5,1],[2,2],[3,1],[1,0]]
Output:8
Explanation:

Take question 0 (5 points, skip 1), skip question 1, take question 2 (3 points, skip 1), skip question 3. Total: 5 + 3 = 8 points.

Constraints

  • 1 ≤ questions.length ≤ 10⁵

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!