码迷,mamicode.com
首页 > 其他好文 > 详细

爬楼梯

时间:2017-03-06 22:05:09      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:color   ret   turn   楼梯   cli   air   i++   for   param   

public class Solution {
    /**
     * @param n: An integer
     * @return: An integer
     */
    int climbStairs(int n) {
       if(n==0)
       {
           return 1;
    }
    int []a=new int[n+1];
    a[0]=1;
    a[1]=1;
       for(int i=2;i<=n;i++) 
       {
           a[i]=a[i-2]+a[i-1];
    }
    return a[n];
    }
};

 

爬楼梯

标签:color   ret   turn   楼梯   cli   air   i++   for   param   

原文地址:http://www.cnblogs.com/ppcwmz/p/6512179.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!