题目描述:
解题思路:
对于每个楼梯状态,我只需要知道之前的一个和之前两个楼梯有多少种方法然后将他们加起来就可以了
代码如下:
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1:
return 1
mylist = [0 for i in range(n)]
mylist[0] = 1
mylist[1] = 2
for i in range(2, n):
mylist[i] = mylist[i-1]+mylist[i-2]
return mylist[n-1]
结果如下:
- THE END -
最后修改:2022年8月16日
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:https://wangyuanzhuo.top/t70-%e7%88%ac%e6%a5%bc%e6%a2%af/
bitcoin
Hiya very nice site!! Man .. Beautiful .. Wonderful .. Theron Martini
bitcoin
I have read so many posts about the blogger lovers but this article is in fact a good article, keep it up. Pablo Wrightsman
king putin
These are genuinely great ideas in concerning blogging. Mose Husseini
king putin
Looking forward to reading more. Great blog article. Much obliged. Sam Belcourt
Loveme
One can learn something new here everyday. Im a regular for most of those blogs, but still didnt know about a couple of them. Faustino Nein
Anna94 wants to trade nude pics with you
I truly appreciate this post. Well, I have put together a long list. Interesting content. I truly appreciate this post. Dustin Carathers
sikis
Very interestting details you have mentioned, appreciate it for putting up. Darrell Soboleski