← All questions
Coding
Find the Largest Submatrix with all 1s
Asked at
DoorDash
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Clarify whether columns may be rearranged.
- 02Accumulate consecutive-one heights per column.
- 03For fixed columns, solve largest rectangle in histogram.
- 04For rearrangeable columns, sort heights each row.
- 05Track maximal area and test zero resets.
Reference answer
Then expect these follow-ups
Why does a monotonic stack find every maximal rectangle?
Tests: correctness reasoning
What changes if columns can be permuted?
Tests: constraint adaptation
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question