Search⌘ K
AI Features

Solution: Maximal Rectangle

Explore a dynamic programming approach to solve the maximal rectangle problem in a binary matrix. Understand how to convert each row into histogram heights and track boundaries to compute the largest rectangle area efficiently. This lesson guides you through the step-by-step implementation and analyzes the time and space complexities involved.

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