Search⌘ K
AI Features

Solution: Maximal Rectangle

Understand how to apply dynamic programming to find the maximal rectangle of 1s in a binary matrix by transforming rows into histograms and calculating areas efficiently. Learn techniques using height, left, and right boundary arrays to optimize the solution in O(m x n) time and O(n) space, preparing you for advanced coding interviews.

Statement

Given a binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.

Constraints:

  • rows ==== matrix.length

  • cols ==== matrix[i].length

  • 11 \leq rows, cols 200\leq 200 ...