Mle occuring in code

i am facing mle. please tell what to do. https://ide.codingblocks.com/s/312890

hi @Akshita99 try using a hashmap to store the dp states instead of a vector

https://ide.codingblocks.com/s/312890 still not working

@Akshita99
what error are you getting?

it worked with top down approach, but is not working with bottom up approach. memory limit exceeded is faced

@Akshita99 it might be because not every value from 1 to n is actually needed, and value of n is really large so the purpose of hashmap was to store only required values. If you use bottom up dp you will end up storing all the values from 1 to n anyway, so that will give MLE due to N being so large

@Akshita99 you may try by making the dp table a global variable

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.