Recursion and backtracking challenges-1

the code is giving me TLE though i have followed the approach told at the hint vedio of Recursion and backtracking challenges of the CP course .Please help me.

hello @hrit04
your solution is correct,but to pass all the test cases u need to use dynamic programming


now i have used dynamic programming now it is giving me runtime error.

image
size of dp array is 1 thats why it is giving run error.

check value of n from constraint section and declare ur dp array with size greaterr than it.

also in the question they have mentioned to take mod so add code for that as well

https://ide.codingblocks.com/s/333952 still only 1 test case has passed

@hrit04
a)check ur value of mod , it is not correct.
b)initilaise ur dp array inside while loop.

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.