mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Update 0070.爬楼梯.md
This commit is contained in:
@ -230,7 +230,20 @@ class Solution:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
```Go
|
||||||
|
func climbStairs(n int) int {
|
||||||
|
if n==1{
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
dp:=make([]int,n+1)
|
||||||
|
dp[1]=1
|
||||||
|
dp[2]=2
|
||||||
|
for i:=3;i<=n;i++{
|
||||||
|
dp[i]=dp[i-1]+dp[i-2]
|
||||||
|
}
|
||||||
|
return dp[n]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user