@@ -0,0 +1,836 @@
+class NumMatrix %7B%0A%0A    private int%5B%5D%5B%5D dp = null;%0A%0A    public NumMatrix(int%5B%5D%5B%5D matrix) %7B%0A        if (matrix.length == 0 %7C%7C matrix%5B0%5D.length == 0) %7B%0A            return;%0A        %7D%0A        int n = matrix.length;%0A        int m = matrix%5B0%5D.length;%0A        %0A        dp = new int%5Bn + 1%5D%5Bm + 1%5D;%0A        for (int r = 0; r %3C n; r++) %7B%0A            for (int c = 0; c %3C m; c++) %7B%0A                dp%5Br + 1%5D%5Bc + 1%5D = dp%5Br + 1%5D%5Bc%5D + dp%5Br%5D%5Bc + 1%5D + matrix%5Br%5D%5Bc%5D - dp%5Br%5D%5Bc%5D;%0A            %7D%0A        %7D%0A    %7D%0A    %0A    public int sumRegion(int row1, int col1, int row2, int col2) %7B%0A        return dp%5Brow2 + 1%5D%5Bcol2 + 1%5D - dp%5Brow1%5D%5Bcol2 + 1%5D - dp%5Brow2 + 1%5D%5Bcol1%5D + dp%5Brow1%5D%5Bcol1%5D;%0A    %7D%0A%7D%0A%0A/**%0A * Your NumMatrix object will be instantiated and called as such:%0A * NumMatrix obj = new NumMatrix(matrix);%0A * int param_1 = obj.sumRegion(row1,col1,row2,col2);%0A */

add 665