【leetcode】Climbing Stairs

来源:互联网 发布:古装电影推荐 知乎 编辑:程序博客网 时间:2024/06/06 19:40

You are climbing a stair case. It takes n steps to reach to the top.

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?


Accept: 1ms

int dp[10000] = {0, 1, 2};int climbStairs(int n) {  if (dp[n] == 0) {    dp[n] = climbStairs(n - 1) + climbStairs(n - 2);  }  return dp[n];}


0 0
原创粉丝点击