일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 컴퓨터의 구조
- 43. Multiply Strings
- kaggle
- Convert Sorted List to Binary Search Tree
- 315. Count of Smaller Numbers After Self
- Decorator
- 운영체제
- Substring with Concatenation of All Words
- t1
- 109. Convert Sorted List to Binary Search Tree
- Python Implementation
- concurrency
- Protocol
- 프로그래머스
- Generator
- data science
- Class
- iterator
- Regular Expression
- 30. Substring with Concatenation of All Words
- Python
- attribute
- shiba
- 밴픽
- LeetCode
- 시바견
- 715. Range Module
- 파이썬
- DWG
- Python Code
Archives
- Today
- Total
Scribbling
LeetCode: 45. Jump Game II 본문
욕심쟁이는 풀 수 있는 문제
class Solution:
def jump(self, nums: List[int]) -> int:
if len(nums) == 1:
return 0
now, jump = 0, 0
while True:
if now + nums[now] >= len(nums) - 1:
return jump + 1
val, next_idx = -1, -1
for i in range(now+1, min(now+nums[now]+1, len(nums))):
if i + nums[i] > val:
val = i + nums[i]
next_idx = i
now = next_idx
jump += 1
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 10. Regular Expression Matching (0) | 2021.09.14 |
---|---|
LeetCode: 43. Multiply Strings (0) | 2021.09.13 |
LeetCode: 43. Multiply Strings (0) | 2021.09.13 |
LeetCode: 42. Trapping Rain Water (0) | 2021.09.12 |
34. Find First and Last Position of Element in Sorted Array (0) | 2021.09.11 |