-
Notifications
You must be signed in to change notification settings - Fork 1
/
Solution.java
36 lines (29 loc) · 922 Bytes
/
Solution.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
@lc id : 1476
@problem : Subrectangle Queries
@author : github.com/rohitkumar-rk
@url : https://leetcode.com/problems/subrectangle-queries/
@difficulty : medium
*/
class SubrectangleQueries {
int[][] rectangle;
public SubrectangleQueries(int[][] rectangle) {
this.rectangle = 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++){
rectangle[i][j] = newValue;
}
}
}
public int getValue(int row, int col) {
return rectangle[row][col];
}
}
/**
* Your SubrectangleQueries object will be instantiated and called as such:
* SubrectangleQueries obj = new SubrectangleQueries(rectangle);
* obj.updateSubrectangle(row1,col1,row2,col2,newValue);
* int param_2 = obj.getValue(row,col);
*/