Skip to content

Latest commit

 

History

History
 
 

climbStairs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

爬楼梯

LeetCode地址

第一次

//抄的
class Solution {
    public int climbStairs(int n) {
        if ( n < 3 ) {
            return n;
        }
        int f1 = 1, f2 = 2, f3 = 3;
        for(int i = 3; i <= n; i++){
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }
}

第二次

2020-04-27,今天上课递归,又讲了一遍。