mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 03:27:07 +00:00
Time: 349 ms (25.27%), Space: 15.2 MB (71.43%) - LeetHub
This commit is contained in:
@@ -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)
|
||||||
Reference in New Issue
Block a user