Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b5150a0

Browse files
committed
Create README - LeetHub
1 parent eae239f commit b5150a0

File tree

1 file changed

+49
-0
lines changed
  • 2140-solving-questions-with-brainpower

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h2><a href="https://leetcode.com/problems/solving-questions-with-brainpower/">2140. Solving Questions With Brainpower</a></h2><h3>Medium</h3><hr><div><p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
2+
3+
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <code>0</code>) and make a decision whether to <strong>solve</strong> or <strong>skip</strong> each question. Solving question <code>i</code> will <strong>earn</strong> you <code>points<sub>i</sub></code> points but you will be <strong>unable</strong> to solve each of the next <code>brainpower<sub>i</sub></code> questions. If you skip question <code>i</code>, you get to make the decision on the next question.</p>
4+
5+
<ul>
6+
<li>For example, given <code>questions = [[3, 2], [4, 3], [4, 4], [2, 5]]</code>:
7+
8+
<ul>
9+
<li>If question <code>0</code> is solved, you will earn <code>3</code> points but you will be unable to solve questions <code>1</code> and <code>2</code>.</li>
10+
<li>If instead, question <code>0</code> is skipped and question <code>1</code> is solved, you will earn <code>4</code> points but you will be unable to solve questions <code>2</code> and <code>3</code>.</li>
11+
</ul>
12+
</li>
13+
</ul>
14+
15+
<p>Return <em>the <strong>maximum</strong> points you can earn for the exam</em>.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong>Example 1:</strong></p>
19+
20+
<pre><strong>Input:</strong> questions = [[3,2],[4,3],[4,4],[2,5]]
21+
<strong>Output:</strong> 5
22+
<strong>Explanation:</strong> The maximum points can be earned by solving questions 0 and 3.
23+
- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions
24+
- Unable to solve questions 1 and 2
25+
- Solve question 3: Earn 2 points
26+
Total points earned: 3 + 2 = 5. There is no other way to earn 5 or more points.
27+
</pre>
28+
29+
<p><strong>Example 2:</strong></p>
30+
31+
<pre><strong>Input:</strong> questions = [[1,1],[2,2],[3,3],[4,4],[5,5]]
32+
<strong>Output:</strong> 7
33+
<strong>Explanation:</strong> The maximum points can be earned by solving questions 1 and 4.
34+
- Skip question 0
35+
- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions
36+
- Unable to solve questions 2 and 3
37+
- Solve question 4: Earn 5 points
38+
Total points earned: 2 + 5 = 7. There is no other way to earn 7 or more points.
39+
</pre>
40+
41+
<p>&nbsp;</p>
42+
<p><strong>Constraints:</strong></p>
43+
44+
<ul>
45+
<li><code>1 &lt;= questions.length &lt;= 10<sup>5</sup></code></li>
46+
<li><code>questions[i].length == 2</code></li>
47+
<li><code>1 &lt;= points<sub>i</sub>, brainpower<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
48+
</ul>
49+
</div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /