Back to problems

Maximal Square and Rectangle in Binary Matrix

Algorithm · Databricks · Medium

Maximum All-1 Square and Rectangle in a Binary Matrix Problem Overview You are given a binary matrix whose entries are only 1 and 0. Determine the area of the largest square made entirely of 1s. Once the square version is complete, you may also be asked to solve the corresponding largest-rectangle problem. Important clarifications: The initial shape is a square. A 1×1 square is valid. Every cell inside the selected shape must contain 1. Return the area rather than the side…

Checking your access…