so please limit the constraint
There will always be tle when doing this question with recursion
True, if this question is done using recursion it would result in a TLE always,
Limiting constraint is not a solution here, instead using Dynamic programming is.
Like that`s the entire reason why we are studying Ds ALgo , so that our code can work for larger constraints.
DP would help u to avoid recomputation which would reduce the time consumed for various operations.
then this question should be in DP section. I wasted a day in optimizing then come to know this
They, its fine, you would have learnt a little, thinking of possible ways of optimising the solution