Time: 349 ms (25.27%), Space: 15.2 MB (71.43%) - LeetHub

This commit is contained in:
Deven
2022-09-19 14:04:27 -04:00
parent 8920a2a843
commit 79417705a8
@@ -0,0 +1,37 @@
class SubrectangleQueries(object):
def __init__(self, rectangle):
"""
:type rectangle: List[List[int]]
"""
self.rectangle = rectangle
def updateSubrectangle(self, row1, col1, row2, col2, newValue):
"""
:type row1: int
:type col1: int
:type row2: int
:type col2: int
:type newValue: int
:rtype: None
"""
for i in range(row1, row2 + 1):
for j in range(col1, col2 + 1):
self.rectangle[i][j] = newValue
def getValue(self, row, col):
"""
:type row: int
:type col: int
:rtype: int
"""
return self.rectangle[row][col]
# Your SubrectangleQueries object will be instantiated and called as such:
# obj = SubrectangleQueries(rectangle)
# obj.updateSubrectangle(row1,col1,row2,col2,newValue)
# param_2 = obj.getValue(row,col)