Skip to content

Commit 7745e06

Browse files
authored
Update 2140-solving-questions-with-brainpower.js
1 parent e92e805 commit 7745e06

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

2140-solving-questions-with-brainpower.js

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* @param {number[][]} questions
3+
* @return {number}
4+
*/
5+
const mostPoints = function(questions) {
6+
const n = questions.length, dp = Array(n + 1).fill(0)
7+
for (let i = n - 1; i >= 0; i--) {
8+
const [gain, p] = questions[i]
9+
dp[i] = Math.max(dp[i + 1], (dp[p + i + 1] || 0) + gain)
10+
}
11+
return dp[0]
12+
};
13+
14+
// another
15+
116
/**
217
* @param {number[][]} questions
318
* @return {number}

0 commit comments

Comments
 (0)