> For the complete documentation index, see [llms.txt](https://leetcode.realtemirov.uz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leetcode.realtemirov.uz/problems/1476.-subrectangle-queries.md).

# 1476. Subrectangle Queries

🟧 Medium

## Solution

My Solution

```go
type SubrectangleQueries struct {
    rows [][]int
}


func Constructor(rectangle [][]int) SubrectangleQueries {
    return SubrectangleQueries{
        rows: rectangle,
    }
}


func (this *SubrectangleQueries) UpdateSubrectangle(row1 int, col1 int, row2 int, col2 int, newValue int)  {
    for i:=row1; i<=row2; i++ {
        for j:=col1; j<=col2; j++ {
            this.rows[i][j] = newValue
        }
    }
}


func (this *SubrectangleQueries) GetValue(row int, col int) int {
    return this.rows[row][col]
}


/**
 * Your SubrectangleQueries object will be instantiated and called as such:
 * obj := Constructor(rectangle);
 * obj.UpdateSubrectangle(row1,col1,row2,col2,newValue);
 * param_2 := obj.GetValue(row,col);
 */
```

![result](https://600345290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrSK2xH3txU3tYyDsT8mQ%2Fuploads%2Fgit-blob-41d4f900370a9fa2e4d4533bf8c93d02fdffbca0%2F1476.png?alt=media)

Leetcode: [link](https://leetcode.com/problems/subrectangle-queries/)
