Skip to content

1476-subrectangle-queries

DevGod
DevGod
Vtuber
/**
* @param {number[][]} rectangle
*/
var SubrectangleQueries = function(rectangle) {
grid = 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 A=row1; A<=row2; A++){
for(let B=col1; B<=col2; B++){
grid[A][B] = newValue;
}
}
return -1;
};
/**
* @param {number} row
* @param {number} col
* @return {number}
*/
SubrectangleQueries.prototype.getValue = function(row, col) {
return grid[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)
*/