Why bottom left goes to n?

lets say we have 4*4 matrix. we want sub matrix (0,0) to (3,3) then, we should iterate between these two points instead of after (3,3)

@premang
Yes your loop will be
for(i=sx;i<=ex;i++)
for(j=sy;j<=ey;j++)
sum += mat[i][j]

what is sx and ex ?

$ Sum Of All Submatrix From A given Matrix - Approach 1

@premang
Lets say you need to calculate submatrix sum from (sx,sy) to (ex,ey)
In your ques that was (0,0) to (3,3)

1 Like

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.