Dsa
Monotonic Stack
Easy
Maximal Rectangle Of 1's
Given a binary matrix, find the area of the largest rectangle containing only 1's. You may assume that all rows are of the same length.
Input Format:
- A number n (rows count), followed by n lines each containing space-separated integers (0 or 1).
Output Format:
- A single integer representing the area of the largest rectangle of 1's.
Example:
Input:
3
1 0 1
1 1 1
1 0 1
Output:
3
Key concepts
monotonic_stackmatrixbinary
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now