function stairSteps(N) {
// store repeat values in memo to prevent repeat computations
const memo = [];
function stepsM(N) {
if (N === 0) return 1;
else if (N < 0) return 0;
if (memo[N] !== undefined) return memo[N];
else {
memo[N] = stepsM(N - 1) + stepsM(N - 2) + stepsM(N - 3);
return memo[N];
}
}
return stepsM(N);
}
function stairSteps(N) {
// store repeat values in memo to prevent repeat computations
const memo = [];
function stepsM(N) {
if (N === 0) return 1;
else if (N < 0) return 0;
if (memo[N] !== undefined) return memo[N];
else {
memo[N] = stepsM(N - 1) + stepsM(N - 2) + stepsM(N - 3);
return memo[N];
}
}
return stepsM(N);
}