Question bank › Matrix
Dsa Matrix Medium

Maximal Square in Matrix

Given a binary matrix (only 0s and 1s), find the area of the largest square containing only 1s and return its area. Input format: - The first line contains two integers 'n' and 'm', the dimensions of the matrix. - The next 'n' lines contain 'm' space-separated integers (0 or 1). Output format: - Print a single integer representing the area of the largest square. Example: Input: 4 5 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Output: 4

Key concepts

matrixmaximaldynamic programming

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.