Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Maximal Rectangle

Hard

Topics
ArrayDynamic ProgrammingStackMatrix

Given a rows-of-characters binary matrix grid filled with '0' and '1', find the largest rectangle containing only '1's and return its area.

Example 1

Input:  matrix = ["10100","10111","11111","10010"]
Output: 6

Example 2

Input:  matrix = ["0"]
Output: 0

Example 3

Input:  matrix = ["1"]
Output: 1

Constraints

  • 1 <= rows, cols <= 200
  • grid[i][j] is '0' or '1'.
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access