How can we know if our dp array would be one dimensional or two dimensional??
It’s very confusing
How can we know if our dp array would be one dimensional or two dimensional??
It’s very confusing
hello @div_yanshu07
first write recurrence relation of the problem.
then see what all parameters are changing on transistion from one state to other.
based of that decide ur dimension of dp array.
for example.
solve(i,j,k)=solve(i-1,j,k) +solve(i,j-1,k)
if u see above relation then u will find that only i and j are the parameters that are changing , so in this problem 2 dimension dp array will be required
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.