Maximal Rectangle

Hard

Topics
ArrayDynamic ProgrammingStackMatrix

Given a rows-of-characters binary matrix grid filled with '0' and '1', find the largest rectangle containing only '1's and return its area.

Example 1

Input:  matrix = ["10100","10111","11111","10010"]
Output: 6

Example 2

Input:  matrix = ["0"]
Output: 0

Example 3

Input:  matrix = ["1"]
Output: 1

Constraints

  • 1 <= rows, cols <= 200
  • grid[i][j] is '0' or '1'.
Run ⌘' · Submit ⌘⏎