My top-down approach(recursion) gives stack overflow error under efficiency.....but my bottom-up approach(iteration) solution is getting accepted, why?


Comment body goes here.


The depth of the recursive calls is causing the issue here and since we cannot use some optimization like tail call optimization so under the constraints set in the judge, it seems you need to use the iterative approach