Find the area of the largest rectangle containing only 1s in a binary matrix.
Given a binary matrix of characters '0' and '1', find the area of the largest axis-aligned rectangle that contains only 1s.
You may choose any contiguous set of rows and columns, but every cell inside the rectangle must be 1.
Your task is to return the maximum possible area.
matrix with m rows and n columns.'0' or '1'.1s.1 <= m, n'0' or '1'.Example 1
Input
matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
Output
6
Explanation
The largest rectangle of 1s has area 6, formed by rows 2-3 and columns 1-3 (0-indexed in a 2x3 block of 1s).
Example 2
Input
matrix = [["0"]]
Output
0
Explanation
There is no rectangle containing only 1s.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.