Staircase Traversal ⇒ it is like the number of ways to change
n, n
function staircaseTraversal(height, maxSteps) {
let cases = new Array(height + 1).fill(0);
cases[0] = 1;
for (let i = 0; i < height + 1; i++) {
for (let step = 1; step <= maxSteps; step++) {
if (step > i) continue;
cases[i] += cases[i - step];
}
}
return cases[height];
}
// Do not edit the line below.
exports.staircaseTraversal = staircaseTraversal;
PreviousThree Number Sort ⇒ counting sort or radix sort ⇒ three pointer with in-place swapNextPhone Number Mnemonics ⇒ can use word and index to create each case without concatenation
Last updated