File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -227,3 +227,32 @@ var uniquePathsWithObstacles = function (obstacleGrid) {
227227};
228228```
229229
230+ ## 2、序列类型(40%)
231+
232+ ##### [ 70. 爬楼梯] ( https://leetcode-cn.com/problems/climbing-stairs/ )
233+
234+ ``` js
235+ var climbStairs = function (n ) {
236+ const res = [1 , 2 ]
237+ for (let i = 2 ; i < n; i++ ) {
238+ res[i] = res[i - 1 ] + res[i - 2 ]
239+ }
240+ return res[n - 1 ]
241+ };
242+ ```
243+
244+ ##### [ 55. 跳跃游戏] ( https://leetcode-cn.com/problems/jump-game/ )
245+
246+ 给定一个非负整数数组 ` nums ` ,你最初位于数组的 ** 第一个下标** 。数组中的每个元素代表你在该位置可以跳跃的最大长度。判断你是否能够到达最后一个下标。
247+
248+ ``` js
249+ var canJump = function (nums ) {
250+ let k = 0
251+ for (let i = 0 ; i < nums .length ; i++ ) {
252+ if (i > k) { return false }
253+ k = Math .max (k, i + nums[i])
254+ }
255+ return true
256+ };
257+ ```
258+
You can’t perform that action at this time.
0 commit comments