mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-04 16:12:47 +08:00
11 lines
265 B
Go
11 lines
265 B
Go
package leetcode
|
|
|
|
func canReach(arr []int, start int) bool {
|
|
if start >= 0 && start < len(arr) && arr[start] < len(arr) {
|
|
jump := arr[start]
|
|
arr[start] += len(arr)
|
|
return jump == 0 || canReach(arr, start+jump) || canReach(arr, start-jump)
|
|
}
|
|
return false
|
|
}
|