일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- kaggle
- Class
- 밴픽
- concurrency
- Convert Sorted List to Binary Search Tree
- attribute
- t1
- 시바견
- Substring with Concatenation of All Words
- shiba
- data science
- LeetCode
- 715. Range Module
- Regular Expression
- Python Code
- Python Implementation
- 30. Substring with Concatenation of All Words
- Decorator
- 파이썬
- DWG
- 109. Convert Sorted List to Binary Search Tree
- 프로그래머스
- 운영체제
- Generator
- iterator
- 315. Count of Smaller Numbers After Self
- 컴퓨터의 구조
- 43. Multiply Strings
- Protocol
- Python
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 |