In the procedure given in the video, we can only find sum of one submatrix at one time. So we have to write Q statements for Q queries (because loop will not work). So if the number of queries is large we cannot follow this procedure.
Doubt in question where Q queries given and we have to find sum of submatrix for all queries
So it is not the best way to solve for n queries. What should we do to solve for n queries??
Such type of quesrtions are formulated to meet the complexity conditions.
So no of queries will always be limited in this question.