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 transform each row into a histogram and track boundaries to compute the largest rectangle area efficiently. This lesson equips you to implement and analyze the solution with linear time and space complexity, essential for 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 ==== ...