Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Increment Submatrices by One
Bookmark
Brute Force
Row-wise 1D Diff
2D Difference Array
Input
3×3, 2 queries
4×4, 3 queries
3×3, same query
Custom
n
=
3
,
queries
=
[[1,1,2,2],[0,0,1,1]]
Q1
[1,1,2,2]
Q2
[0,0,1,1]
0
1
2
0
1
2
0
0
0
0
0
0
0
0
0
Q1
[1,1,2,2]
Q2
[0,0,1,1]
0
1
2
0
1
2
0
0
0
0
0
0
0
0
0
Q1
[1,1,2,2]
Q2
[0,0,1,1]
0
1
2
0
1
2
0
0
0
0
1
1
0
1
1
Q1 [1,1,2,2]:
+1 to every cell in the rectangle
Q1
[1,1,2,2]
Q2
[0,0,1,1]
0
1
2
0
1
2
1
1
0
1
2
1
0
1
1
Q2 [0,0,1,1]:
+1 to every cell in the rectangle
Q1
[1,1,2,2]
Q2
[0,0,1,1]
0
1
2
0
1
2
1
1
0
1
2
1
0
1
1
All queries applied
algo
master
.
io
Step:
Start: 3 x 3 grid of zeros, 2 queries to apply cell by cell
0 / 3
Input
3×3, 2 queries
4×4, 3 queries
3×3, same query
Custom
n
=
3
,
queries
=
[[1,1,2,2],[0,0,1,1]]
0 / 3
algo
master
.
io
Step:
Start: 3 x 3 grid of zeros, 2 queries to apply cell by cell