if we take prefix matrix into consideration, prefix matrix will take O(n^2) complexity to build but in the video it is explained that it will take O(1) complexity to solve. The mentor didnt take building prefix matrix into consideration
Submatrix sum query best case O(1)
hello @
yeah building matrix will be n^2. mentor is talking about time to handle each query which will be O(1) after precomputation
so what is the best approach brute force one or prefix matrix one as both will take n^2 if we look at the entire code.
to handle MULTIPLE queries the prefix precomputation approach is better.