Memory Limit Exceeded

My memoisation solution is giving me MLE, please review my code :- https://ide.codingblocks.com/s/266645

hello @D19APPND0003
value of n can be upto 10^9 and array of size 10^9 will consume too much memory.
and that is the reason why ur code is giving mle error.

use map in place of vector and top down dp in place of bottom up dp