Practice Increment Submatrices by One
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Start with an n by n zero matrix. Each query [row1,col1,row2,col2] adds 1 to every cell in its rectangle, including all boundary rows and columns. Return the matrix after every query has been applied.
Source: Increment Submatrices by One on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 3, queries = [[1,1,2,2],[0,0,1,1]]
Output
[[1,1,0],[1,2,1],[0,1,1]]
# Example 2
Input
n = 2, queries = [[0,0,1,1]]
Output
[[1,1],[1,1]]
Constraints
1 <= n <= 500
1 <= queries.length <= 10^4
0 <= row1i <= row2i < n
0 <= col1i <= col2i < n
Related LeetCode Problems
Practice more problems similar to Increment Submatrices by One.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.