In the given video value of P,Q and R will garbage value for the case of i=0, and j=0…
please explain…
Sum Of All Submatrix From A given Matrix - Approach 2
Hello @Bansaljatin05
Here while fetching the prefixes P, Q, and R from the prefix matrix we will make sure that we are not accessing anything out of the bounds of the matrix using if statements.
Like to calculate R we will do
int R;
if(li != 0 && lj != 0) {
R = prefixMatrix[li - 1][lj - 1];
}
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.