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 309c169

Browse files
solved leetcode daily challenge, 2140. Solving Questions With Brainpower
See: Why: How: Tags:
1 parent d01336b commit 309c169

File tree

1 file changed

+50
-0
lines changed
  • LeetCode/2140._Solving_Questions_With_Brainpower

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <bits/stdc++.h>
2+
#include <gtest/gtest.h>
3+
using namespace std;
4+
5+
//// START
6+
/*
7+
## 2140. Solving Questions With Brainpower
8+
9+
*/
10+
11+
class Solution {
12+
public:
13+
long long mostPoints(vector<vector<int>> &questions) {
14+
vector<long long> dp(questions.size());
15+
dp[dp.size() - 1] = questions[questions.size() - 1][0];
16+
for (int i = dp.size() - 2; i >= 0; i--) {
17+
long long score = questions[i][0];
18+
if (i + questions[i][1] + 1 < questions.size()) {
19+
score += dp[i + questions[i][1] + 1];
20+
}
21+
dp[i] = max(dp[i + 1], score);
22+
}
23+
return dp[0];
24+
}
25+
};
26+
27+
//// END
28+
struct T {};
29+
30+
TEST(Solution, test) {
31+
T ts[] = {
32+
{
33+
34+
},
35+
{
36+
37+
},
38+
39+
};
40+
41+
for (T t : ts) {
42+
Solution solution;
43+
}
44+
}
45+
46+
int main() {
47+
testing::InitGoogleTest();
48+
49+
return RUN_ALL_TESTS();
50+
}

0 commit comments

Comments
(0)

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