Sum of submatrix(approach3)


not understanding value of x and y and then further solution,please explain .

In this approach our aim is to calculate contribution of each cell

as explained in video how to calculate this

we have to select 2 points top left and bottom right
for top left selected rectangle is from 0,0 to i,j
and no of element in it is length * breadth
length=i+1;
breadth=j+1;
so it is (i+1)(j+1)
similarly for bottom right point selection
length=(n-1 -i +1)=n-i;
breadth=(n-1 -j +1)=n-j
so it is (n-i)(n-j)

Check the code from here https://www.geeksforgeeks.org/sum-of-all-submatrices-of-a-given-matrix/

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.