#K63417. Largest Rectangle in a Binary Matrix
Largest Rectangle in a Binary Matrix
Largest Rectangle in a Binary Matrix
Given a 2D binary matrix filled with 0's and 1's, your task is to find the area of the largest rectangle that contains only 1's. The rectangle must have sides parallel to the matrix axes. For a rectangle with height (h) and width (w), the area is computed as (A = h \times w). Read the input as described and output the maximum area found.
inputFormat
The input is given via standard input (stdin). The first line contains two space-separated integers (n) and (m), representing the number of rows and columns of the matrix respectively. This is followed by (n) lines, each containing (m) space-separated integers (either 0 or 1) representing the matrix.
outputFormat
Output a single integer to standard output (stdout), which is the area of the largest rectangle containing only 1's.## sample
4 4
1 0 1 0
1 0 1 1
1 1 1 1
1 0 0 1
4