I am learning dynamic programming I have observed when solving recursive code soemtimes we check out of bound conditiosns first then check other base cases and sometimes it is we check the other bases first and then after that we check the out of bound conditiosn how to figure out which to choose
FOR EXAMPLE IN SOME PROBLEM IT IS LIKE
`if(i<0||j<0||i>=matrix.length||j>=matrix[0].length)
{
return Integer.MAX_VALUE;
}
if(i==matrix.length-1)
{
return matrix[i][j];
}
WHILE IN OTHER cases IT IS LIKE
if(i==matrix.length-1)
{
return matrix[i][j];
}
if(i<0||j<0||i>=matrix.length||j>=matrix[0].length)
{
return Integer.MAX_VALUE;
}`
HOW TO FIGURE OUT WHEN TO CHOOSE WHICH PLEASE HELP I am confused also please tell me sometips to get good at bottom up dp
I am confused when to choose which way when solving recuesion problems
Silent Geek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.