로딩
요청 처리 중입니다...

JAVA_LeetCode 304_Range Sum Query 2D - Immutable

 JAVA_LeetCode 304_Range Sum Query 2D - Immutable

JAVA_LeetCode 304_Range Sum Query 2D - Immutable 풀이 class NumMatrix { private int[][] prefix; public NumMatrix(int[][] matrix) { int m = matrix.length; int n = matrix[0].length; prefix = new int[m + 1][n + 1]; // 점차 우측 하단으로 가면서 해당 요소 값을 계산하면서 초기화해준다. for(int i = 1; i <= m; ++i){ for(int j = 1; j <= n; ++j){ prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + matrix[i - 1][j - 1]; } } } public int sumRegion(int row1, int col1, int row2, int col2) { // 0행 0열 기준으로 파라미터를 받아서 ...