to calcukate the prefix sum matrix we need to loop through the whole matrix
. so wont the complexity be O(qnm) and the space complexity be O(n*m)? then brute force is better than this?
Submatrix sum doubt
@Shreya-Gupta-2383169445069382
hello shreya,
to prepare prefix sum matrix we need O(n*m) opertions
after that for for each query we can answer it in O(1) so O(q) for q queries
so overall complexity will be O(q+n*m)