Question bank › Matrix
Dsa Matrix Medium

Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Input Format: The first line contains two integers m and n. The next m lines each contain n space-separated integers (0 or 1). Output Format: Print a single integer, 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 0 0 0 1 0 Output: 4

Key concepts

matrixmaximalsquaredp

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.