Search⌘ K
AI Features

Solution: Maximal Rectangle

Explore how to use dynamic programming to compute the largest rectangle containing only ones in a binary matrix. Understand how to transform each row into a histogram and use auxiliary arrays to track boundaries and heights for efficient area calculation. Gain the skills to solve this optimization problem with a linear time approach.

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 ...