Given a 2D matrix, handle multiple queries asking for the sum of elements inside a rectangle defined by its upper left corner and lower right corner .
This extends the 1D prefix sum to two dimensions. The same trade-off applies: preprocessing for queries. Read the problem. Notice there can be queries on a matrix.