Segmentation error in code

Although I solved it using a different method, this method should work too. Please help. I have treated it like unbounded knapsack problem.

https://practice.geeksforgeeks.org/problems/count-ways-to-nth-stairorder-does-not-matter5639/1/?category[]=Dynamic%20Programming&category[]=Dynamic%20Programming&problemStatus=unsolved&difficulty[]=0&difficulty[]=1&page=1&query=category[]Dynamic%20ProgrammingproblemStatusunsolveddifficulty[]0difficulty[]1page1category[]Dynamic%20Programming

hello @anshufirefox

yeah it shuld work , ur approach is correct.
probably becuase of too much memory allocation becusse of dp array and recusion ,stack limit is getting exceeded and it is showing run error

Thanks :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.