动态规划

三个概念:最有子结构,边界,状态转化

https://www.cnblogs.com/cthon/p/9251909.html

爬楼梯问题

public static int getWay(int i) {
        if (i<1){
            return 1;
        }
        if (i==1){
            return 1;
        }
        if (i==2){
            return 2;
        }
        int a=1;
        int b=2;
        int temp=0;
        //因为下一层的层数是前两层相加
        for (int j = 3; j <= i; j++) {
            temp = a + b;
            a = b;
            b = temp;
        }
        return temp;
    }
原文地址:https://www.cnblogs.com/xiaoruirui/p/15033144.html