---
title: "Comment by Jack Follansbee on \"How to Solve the Staircase Problem with JavaScript using Memoization\" | Hashnode"
description: "Pardon me for rewriting in Python. My code runs without recursion and at about the same speed. def StairCaseMemo ( N ): memo = {} def stepsM ( N ): if N == 0 :"
url: "https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a/comment/62db7a5dcf7a8a6d54f0605b"
---

[Discussion](https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a)

Comment [How to Solve the Staircase Problem with JavaScript using Memoization](https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a)

[Jack Follansbee](https://hashnode.com/@MrPeach)

[Jul 23, 2022](https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a/comment/62db7a5dcf7a8a6d54f0605b)

Pardon me for rewriting in Python.

My code runs without recursion and at about the same speed.

```
def StairCaseMemo(N):
    memo = {}

    def stepsM(N):
        if N == 0: return 1
        elif N<0: return 0
        if N in memo.keys(): return memo[N]
        else:
            memo[N] = stepsM(N - 1) + stepsM(N - 2) + stepsM(N - 3);
            return memo[N];
    print(stepsM(N))

def StairCaseMine(limit):
    # initial setup
    array = {}
    array[0] = 1
    array[1] = array[2] = index = 0
    while index < limit:
        count = array[index]
        array[index+1] += count
        array[index+2] += count
        array[index+3] = count
        index += 1
    print(array[limit])
```

Enjoy!
