Skip to content

Commit

Permalink
Update 55.jump-game.md
Browse files Browse the repository at this point in the history
  • Loading branch information
azl397985856 authored Apr 17, 2020
1 parent 9936c26 commit 0d5a2ef
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions problems/55.jump-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ Explanation: You will always arrive at index 3 no matter what. Its maximum

## 思路

这道题目是一道典型的`回溯`类型题目。
思路就是用一个变量记录当前能够到达的最大的索引,我们逐个遍历数组中的元素去更新这个索引。
变量完成判断这个索引是否大于数组下表即可。
这道题目是一道典型的`贪心`类型题目。思路就是用一个变量记录当前能够到达的最大的索引,我们逐个遍历数组中的元素去更新这个索引。变量完成判断这个索引是否大于数组下表即可。
## 关键点解析

- 建模 (记录和更新当前位置能够到达的最大的索引即可)
Expand All @@ -38,7 +36,6 @@ Explanation: You will always arrive at index 3 no matter what. Its maximum
* 语言支持: Javascript,Python3

```js

/**
* @param {number[]} nums
* @return {boolean}
Expand Down Expand Up @@ -71,3 +68,11 @@ class Solution:
return True
return _max >= _len - 1
```

***复杂度分析***
- 时间复杂度:$O(N)$
- 空间复杂度:$O(1)$

更多题解可以访问我的LeetCode题解仓库:https://github.com/azl397985856/leetcode 。 目前已经30K star啦。

大家也可以关注我的公众号《脑洞前端》获取更多更新鲜的LeetCode题解

0 comments on commit 0d5a2ef

Please sign in to comment.