Submatrix query

please go thru my code , i have done it in simpler way but want to verify it.

Hey @Diwyanshu
While your code is perfect it is not the optimum approach
Lets say you get Q queries
Each query has 0 0 n-1 n-1 as input
In that case your TC will be Q*(N^2)
While the approach we discussed takes N^2 preprocessing time then 0(1) for each query which means 0(Q) TC

So I encourage you to try and implement the approach in the video.

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.