[LeetCode] Subrectangle Queries

SubrectangleQueries의 생성자에 인자로 들어오는 rectangle을 matrix에 저장한다.updateSubrectangle 메서드에서 row1부터 row2까지 행마다 col1부터 col2까지의 열만큼 newValue로 값을 변경한다.getValue 메서드에서는 row행의 col열의 값을 리턴한다.class SubrectangleQueries {
int[][] matrix;
public SubrectangleQueries(int[][] rectangle) {
this.matrix = rectangle;
}
public void updateSubrectangle(int row1, int col1, int row2, int col2, int newValue) {
for(int i = row1; i <= row2; i++) {
for(int j = col1; j <= col2; j++) {
matrix[i][j] = newValue;
}
}
}
public int getValue(int row, int col) {
return matrix[row][col];
}
}