Back to problems

Maximal Rectangle (LeetCode 85)

Algorithm · Salesforce · Hard

You are given a binary matrix grid with m rows and n columns, where each element is either the character '0' or '1'. Return the area of the largest axis‑aligned rectangle that consists entirely of '1' characters. An axis‑aligned rectangle is defined by two opposite corners; its area is simply the number of '1' cells it covers. Example 1: Explanation: The maximal rectangle is the 2 × 2 block at rows 1‑2 and columns 0‑1 (all '1's), giving area 4. Example 2: Explanation: A…

Checking your access…