Background
I want to buy an plot of land and build my house on it. My house should be rectangular, and as large as possible; however, the available plots have lots of rocky areas that I cannot build on, and I'm having trouble fitting a potential house on the plots. I want you to write a program that analyzes the plots for me.
Input and output
Your input is a rectangular 2D array of bits, of size at least 1×1, in any reasonable format.
The array represents a plot of land; 1
s are "good" areas where I could build my house, and 0
s are "rocky" areas where the house cannot be built.
Your output shall be the maximal area of a solid rectangle of 1
s in the input array.
It represents the area of the largest house I could build on the plot.
Note that if there are no 1
s in the input, then the output is 0
.
Example
Consider the input
101
011
111
The largest rectangle of 1
s is the 2×2 rectangle in the lower right corner.
This means that the correct output is 4
.
Rules and scoring
You can write a full program or a function. The lowest byte count wins, and standard loopholes are disallowed.
Test cases
0
-> 0
1
-> 1
00
00
-> 0
01
10
-> 1
01
11
-> 2
111
010
111
-> 3
101
011
111
-> 4
0111
1110
1100
-> 4
1111111
1110111
1011101
-> 7
111011000
110111100
001111110
011111111
001111110
000111100
000011000
-> 20
000110000
110110010
110111110
110011100
010011111
111111111
111101110
-> 12
plow
. \$\endgroup\$