leetcode 2140. Solving Questions With Brainpower
3510 ワード
https://leetcode.com/problems/solving-questions-with-brainpower
class Solution:
def mostPoints(self, questions: List[List[int]]) -> int:
def f(qs, idx, memo):
if idx >= len(qs):return 0
if idx in memo: return memo[idx]
p,b = qs[idx]
skip = f(qs, idx+1, memo)
solve = p + f(qs, idx+b+1, memo)
ans = max(skip, solve)
memo[idx] = ans
return ans
return f(questions, 0, {})
Reference
この問題について(leetcode 2140. Solving Questions With Brainpower), 我々は、より多くの情報をここで見つけました https://velog.io/@jhcho/leetcode-2140.-Solving-Questions-With-Brainpowerテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol