Skip to content

Commit 57b2a21

Browse files
committed
feat: Add solution for LeetCode problem 55
1 parent 1abcc90 commit 57b2a21

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

jump-game/WhiteHyun.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// 55. Jump Game
3+
// https://leetcode.com/problems/jump-game/description/
4+
// Dale-Study
5+
//
6+
// Created by WhiteHyun on 2024/07/20.
7+
//
8+
9+
class Solution {
10+
func canJump(_ numbers: [Int]) -> Bool {
11+
var goal = numbers.endIndex - 1
12+
13+
for index in numbers.indices.dropLast().reversed() where index + numbers[index] >= goal {
14+
goal = index
15+
}
16+
17+
return goal == 0
18+
}
19+
}

0 commit comments

Comments
 (0)