Maximal Square Problem

Maximal Square Problem — ExecCode Medium DSA Practice

Solve the Maximal Square problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given an m×n binary matrix filled with 0s and 1s, find the largest square containing only 1s and return its area. For Maximal Square, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.

Examples

Input matrix = [["1", "1"], ["1", "1"]]; Output 4

Constraints

1 ≤ m,n ≤ 300 matrix[i][j] is "0" or "1"

Practice Maximal Square free on ExecCode. Browse DSA problems, topic map, and placement guides.