Given a 2D integer matrix, answer many queries asking for the sum of the elements inside a rectangle whose upper-left corner is `(row1, col1)` and lower-right corner is `(row2, col2)`, inclusive.
Implement the `NumMatrix` class:
- `NumMatrix(int[][] matrix)` initializes the object with the matrix.
- `int sumRegion(int row1, int col1, int row2, int col2)` returns the sum of the rectangle.
Each `sumRegion` call must run in O(1) time.
Given a 2D integer matrix, answer many queries asking for the sum of the elements inside a rectangle whose upper-left corner is (row1, col1) and lower-right corner is (row2, col2), inclusive.
Implement the NumMatrix class:
NumMatrix(int[][] matrix) initializes the object with the matrix.
int sumRegion(int row1, int col1, int row2, int col2) returns the sum of the rectangle.