Maximal Rectangle

Hard · Stack & Monotonic Stack · about 30 minutes

Asked at Google, Microsoft, Amazon, Bloomberg, Meta, Epic Games.

Given an m × n binary matrix of 0s and 1s, find the largest rectangle containing only 1s and return its area.

Related guides