일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 매일
- Problem Solving
- 뭐든
- 쓰릴오브파이트
- 만화도
- 프로젝트
- 사이드
- 개발자
- English
- 화상영어
- 미드시청
- 3줄정리
- realclass
- 파비최
- 10분
- Daily Challenge
- FIT XR
- 잡생각
- 운동
- 괜찮음
- Writing
- 월간
- 영어원서읽기
- leetcode
- 리얼 클래스
- 읽기
- 스탭퍼
- 영어공부
- 30분
- 링피트
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.05.12 Today's Challenge 본문
https://leetcode.com/problems/solving-questions-with-brainpower/
Solving Questions With Brainpower - LeetCode
Can you solve this real interview question? Solving Questions With Brainpower - You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri]. The array describes the questions of an exam, where you have to process the qu
leetcode.com
전형적인 DP 문제.
이제 한동안 DP만 나오려나
class Solution:
def mostPoints(self, questions: List[List[int]]) -> int:
n = len(questions)
dp = [0] * n
dp[-1] = questions[-1][0]
for i in range(n-2, -1, -1):
dp[i] = questions[i][0]
skip = questions[i][1]
if i + skip + 1 < n:
dp[i] += dp[i+skip+1]
dp[i] = max(dp[i], dp[i+1])
return dp[0]
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.05.14 Today's Challenge (0) | 2023.05.14 |
---|---|
2023.05.13 Today's Challenge (1) | 2023.05.13 |
2023.05.11 Today's Challenge (0) | 2023.05.11 |
2023.05.10 Today's Challenge (0) | 2023.05.10 |
2023.05.09 Today's Challenge (0) | 2023.05.09 |
Comments