> For the complete documentation index, see [llms.txt](https://algorithm.prettylog.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algorithm.prettylog.com/algorithm-problems/algoexpert/medium/staircase-traversal-it-is-like-the-number-of-ways-to-change.md).

# Staircase Traversal ⇒ it is like the number of ways to change

![](/files/Mnf41Yr5Pzwa8yvy5T4A)

* n, n

```jsx
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;

```
