일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 운동
- 리얼 클래스
- 쓰릴오브파이트
- 프로젝트
- 링피트
- Problem Solving
- 괜찮음
- 미드시청
- 화상영어
- 잡생각
- Daily Challenge
- 만화도
- 개발자
- 10분
- FIT XR
- 영어공부
- 스탭퍼
- 매일
- 파비최
- 읽기
- 3줄정리
- 뭐든
- 월간
- Writing
- 30분
- English
- leetcode
- 사이드
- 영어원서읽기
- realclass
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.02.08 Today's Challenge 본문
https://leetcode.com/problems/jump-game-ii/
Jump Game II - LeetCode
Jump Game II - You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0]. Each element nums[i] represents the maximum length of a forward jump from index i. In other words, if you are at nums[i], you can jump to
leetcode.com
ChatGPT를 통해 솔루션을 받아 보았다.
ㅠ_ㅠ 이렇게 간단한 문제였다니..
혹시 영어가 문제인건가..?!
class Solution:
def jump(self, nums: List[int]) -> int:
n = len(nums)
dp = [float('inf')] * n
dp[0] = 0
for i in range(n-1):
for j in range(1, nums[i]+1):
if i + j < n:
dp[i+j] = min(dp[i+j], dp[i] + 1)
return dp[n-1]
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.02.10 Today's Challenge (0) | 2023.02.10 |
---|---|
2023.02.09 Today's Challenge (0) | 2023.02.09 |
2023.02.07 Today's Challenge (0) | 2023.02.07 |
2023.02.06 Today's Challenge (0) | 2023.02.06 |
2023.02.05 Today's Challenge (0) | 2023.02.05 |
Comments