i have done many changes to my code -“https://ide.codingblocks.com/s/96619”…
but then also i am getting all the outputs not getting only one answer,how to stop the recursion process after getting an ans
Getting all the sequence
it is still giving wrong answer
i am not getting it even if my answer is correct but it is giving wrong answer ans time limit exceeded (code-“https://ide.codingblocks.com/s/96619”).
hey @Ayusinha, Actually this is pure DP question and if we do this with recurion with such high constraints, it usually give TLE or Wrong answer.
If you have completed the DP topic try to implement is using DP. If not, consider this once till the time you reach to DP https://ide.codingblocks.com/s/97518
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.