I have solved it using bottom up approach but trying to solve it using top down approach but getting rte while the same code is getting accepted at leetcode.
Getting run time error
@darkshadow2708
Your code is correct, but in C++ the size stack is ~ 10000 calls.
It may be bigger on some machines, but the default size is of 1e4 system calls only.
and in the question N is very large ~1e6. so your code gives run error.
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.