File tree 1 file changed +50
-0
lines changed
LeetCode/2140._Solving_Questions_With_Brainpower
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments