Dsa
Matrix
Hard
Maximum Square Submatrix
Given a binary matrix, find the largest square containing only 1s and return its area.
Example:
Input:
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
0 0 1 0 0
Output:
9 (since the largest square has a side length of 3)
Key concepts
matrixdynamic programmingsubmatrix
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