Skip to content

Commit 193aa1f

Browse files
committed
添加题70,55
1 parent 22feb5c commit 193aa1f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎基础算法篇/动态规划.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
varclimbStairs=function (n){
236+
constres= [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+
varcanJump=function (nums){
250+
let k =0
251+
for (let i =0; i <nums.length; i++){
252+
if (i > k){returnfalse }
253+
k =Math.max(k, i + nums[i])
254+
}
255+
returntrue
256+
};
257+
```
258+

0 commit comments

Comments
(0)