leetcode 2140. Solving Questions With Brainpower

wonderful world·2022년 1월 22일
0

leetcode

목록 보기
18/21

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, {})
           
profile
hello wirld

0개의 댓글