Skip to content

Commit cd2035f

Browse files
authored
Merge pull request neetcode-gh#1407 from zim0369/jump-game
Create 55-Jump-Game.rs
2 parents 2ea01d6 + b20cff5 commit cd2035f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

rust/55-Jump-Game.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub fn can_jump(nums: Vec<i32>) -> bool {
2+
let mut goal = nums.len() - 1;
3+
4+
for i in (0..goal).rev() {
5+
if i + nums[i] as usize >= goal {
6+
goal = i;
7+
}
8+
}
9+
10+
goal == 0
11+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy