Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Maximal Rectangle
Bookmark
Brute Force
Histogram
Width DP
Input
Example 1
Single zero
All ones (3x2)
Custom
matrix
=
[["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
4x5
maxArea =
0
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
find the largest all-1s rectangle in the grid
4x5
maxArea =
0
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
find the largest all-1s rectangle in the grid
4x5
maxArea =
3
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
2 cells are 0
: this rectangle is out
4x5
maxArea =
4
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
this rectangle holds
4
of its
6
cells as 1s
4x5
maxArea =
4
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
this rectangle holds
8
of its
12
cells as 1s
4x5
maxArea =
4
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
this rectangle holds
4
of its
5
cells as 1s
4x5
maxArea =
4
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
1 cell are 0
: this rectangle is out
4x5
maxArea =
6
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
this rectangle holds
4
of its
4
cells as 1s
4x5
maxArea =
6
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
this rectangle holds
2
of its
2
cells as 1s
4x5
maxArea =
6
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
this rectangle holds
1
of its
1
cells as 1s
4x5
maxArea =
6
1
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
0
maximal rectangle area =
6
algo
master
.
io
Step:
Find the largest all-1s rectangle. Count the 1s in every rectangle and keep the full ones
0 / 643
Input
Example 1
Single zero
All ones (3x2)
Custom
matrix
=
[["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
0 / 643
algo
master
.
io
Step:
Find the largest all-1s rectangle. Count the 1s in every rectangle and keep the full ones