【leetcode】70. 爬楼梯

 

int climbStairs(int n){
    int i, pre=1, prepre=0, cur=0;
    for(i=1; i<=n; i++){
        cur=pre+prepre;
        prepre=pre;
        pre=cur;
    }
    return cur;
}

 

posted @ 2020-11-27 21:11  温暖了寂寞  阅读(65)  评论(0编辑  收藏  举报