mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 02:53:31 +08:00
更新 0045.跳跃游戏II 排版格式修复
This commit is contained in:
@ -25,9 +25,9 @@
|
||||
说明:
|
||||
假设你总是可以到达数组的最后一个位置。
|
||||
|
||||
# 视频讲解
|
||||
## 算法公开课
|
||||
|
||||
**《代码随想录》算法视频公开课:[贪心算法,最少跳几步还得看覆盖范围 | LeetCode: 45.跳跃游戏 II](https://www.bilibili.com/video/BV1Y24y1r7XZ),相信结合视频在看本篇题解,更有助于大家对本题的理解**。
|
||||
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[贪心算法,最少跳几步还得看覆盖范围 | LeetCode: 45.跳跃游戏 II](https://www.bilibili.com/video/BV1Y24y1r7XZ),相信结合视频在看本篇题解,更有助于大家对本题的理解**。
|
||||
|
||||
## 思路
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
|
||||
**图中覆盖范围的意义在于,只要红色的区域,最多两步一定可以到!(不用管具体怎么跳,反正一定可以跳到)**
|
||||
|
||||
## 方法一
|
||||
### 方法一
|
||||
|
||||
从图中可以看出来,就是移动下标达到了当前覆盖的最远距离下标时,步数就要加一,来增加覆盖距离。最后的步数就是最少步数。
|
||||
|
||||
@ -90,7 +90,7 @@ public:
|
||||
* 空间复杂度: O(1)
|
||||
|
||||
|
||||
## 方法二
|
||||
### 方法二
|
||||
|
||||
依然是贪心,思路和方法一差不多,代码可以简洁一些。
|
||||
|
||||
@ -469,3 +469,4 @@ impl Solution {
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
Reference in New Issue
Block a user