- 2023-08-18[LeetCode][70]climbing-stairs
ContentYouareclimbingastaircase.Ittakesnstepstoreachthetop.Eachtimeyoucaneitherclimb1or2steps.Inhowmanydistinctwayscanyouclimbtothetop? Example1:Input:n=2Output:2Explanation:Therearetwowaystoclimbtothet
- 2023-06-19Climbing Stairs
Youareclimbingastaircase.Ittakesnstepstoreachthetop.Eachtimeyoucaneitherclimb1or2steps.Inhowmanydistinctwayscanyouclimbtothetop?Example1:Input:n=2Output:2Explanation:Therearetwowaystoclimbtothetop.1.1
- 2023-05-2670. Climbing Stairs刷题笔记
问题描述该题考察的是动态规划classSolution:defclimbStairs(self,n:int)->int:dp=[0]*nifn==1:return1dp[0]=1dp[1]=2foriinrange(2,n):dp[i]=dp[i-1]+dp[i-2]ret
- 2023-01-1170. Climbing Stairs
第一次自己想到用dpclassSolution{public:intdp[100];intclimbStairs(intn){dp[0]=1;dp[1]=1;for(inti=2;i<100;++i)dp[i]=dp[i-1]
- 2022-11-07山高人为峰,讲述一位年轻女性的攀岩生活
文/ 王不留(微信公众号:考研英语笔记)AloftynewbookaboutclimbingMostcelebratedmountaineershavebeenmen.Butmanyofthebestbooksaboutclimbinga
- 2022-10-18LeetCode 70. Climbing Stairs
题目classSolution{public:intdp[10005];intclimbStairs(intn){dp[1]=1;dp[2]=2;for(inti=3;i<=n;i++)
- 2022-10-0570.climbing-stairs 爬楼梯
题目描述70.爬楼梯解题思路本质上与斐波那契数是一样的:\(a_n=a_{n-1}+a_{n-2}\)构建for循环来遍历。代码classSolution{public:intclimbStairs(i