Sir , in this question we are storing just i , j in 2D matrix of dp array , what if overlapping sub structure are not in same year,
then i think this would be wrong.
I think we should use 3D matrix to store year also to match year also for overlapping sub structure.
Doubt of overlapping substructure
Hey @vg5823967
The answer to your question is a little bit intuitive. When you store i,j you’re storing year as well. How ? The year is equal to N - ( j - i ), where N is size of array. So it is still 2D dp question.
If your doubt is resolved please mark it as closed.
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.