Carimus编码问题
代码
function climbingStairs(stairs: number) {
if (stairs <= 2) return stairs;
return climbingStairs(stairs - 1) + climbingStairs(stairs - 2);
}
function climbingStairsDriver(stairs: number) {
if(stairs < 0) {
alert("Number of stairs can not be negative");
}
let answer = climbingStairs(stairs);
return setCombinationsToTop(answer);
}
分析
由于在递归算法的多个步骤中(无双