Data Structure & Algorithm: Level-1 Problem #20. Climbing Stairs

Given a staircase of N stairs, if we can move up either one step or two steps at a time, how many different ways are there to climb to the top?

Sample Input: 20

Sample Output: 10946

For a staircase with 20 steps, there are 10946 distinct ways to get to the top.


数据结构和算法:初级练习题 #20 – 爬楼梯


如果一段楼梯有N节阶梯,每次我们可以爬一阶或者两阶台阶,计算从楼梯低端到顶端总共有多少不同的走法。

输入样例: 20

输出样例: 10946

一段20个台阶的楼梯,按照规则总共有10946种不同的走法。


Python Solution

Climbing Stairs