This question where we have to solve it using sum of sub matrix approach 2

how to solve it . i am getting error in my code . also i am not able to understand this question . please help with this question where i have to calculate the sum of sub array matriz where query is given

hello @hunter001

here in the question u are given a 2d array. and q queries.
in each query u r asked to print sum of submatrix(starting and ending coordinates of submatrix will be given for each query).

so to answer this we can either run brute force (but that will be time consuming )
or we can take help of prefix sum array to answer each query in O(1)

For code refer this ->

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.