Getting run error for 1 test case

i am getting one run-error,
this is the code.

always prefer bottom up dp then top down dp, because top down dp using recursion results in stack overflow , due to too much memory usage

convert this solution using recursion to solutionn using tabular method
like this;