-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsubrectangle_queries.js
More file actions
38 lines (35 loc) · 935 Bytes
/
subrectangle_queries.js
File metadata and controls
38 lines (35 loc) · 935 Bytes
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
37
38
/**
* @param {number[][]} rectangle
*/
var SubrectangleQueries = function(rectangle) {
this.rectCoords = rectangle;
};
/**
* @param {number} row1
* @param {number} col1
* @param {number} row2
* @param {number} col2
* @param {number} newValue
* @return {void}
*/
SubrectangleQueries.prototype.updateSubrectangle = function(row1, col1, row2, col2, newValue) {
for(let i = row1; i <= row2; i++) {
for(let j = col1; j <= col2; j++) {
this.rectCoords[i][j] = newValue;
}
}
};
/**
* @param {number} row
* @param {number} col
* @return {number}
*/
SubrectangleQueries.prototype.getValue = function(row, col) {
return this.rectCoords[row][col];
};
/**
* Your SubrectangleQueries object will be instantiated and called as such:
* var obj = new SubrectangleQueries(rectangle)
* obj.updateSubrectangle(row1,col1,row2,col2,newValue)
* var param_2 = obj.getValue(row,col)
*/