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!