Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 517d584

Browse files
Create 45.py
1 parent eee7127 commit 517d584

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎1-100/45.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution(object):
2+
def jump(self, nums):
3+
ans = 0
4+
n = len(nums)
5+
currEnd = 0
6+
currFarthest = 0
7+
for i in range(n-1):
8+
currFarthest = max(currFarthest, i + nums[i])
9+
if i == currEnd:
10+
ans += 1
11+
currEnd = currFarthest
12+
13+
return ans

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /