Measure the Largest All-One Square Area

Quick Overview

Compute maximal all-one square area with rolling side-length summaries and correct character-cell semantics.

Measure the Largest All-One Square Area

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem Find the largest square whose cells are all character `'1'` in a rectangular binary matrix, and return its area. Cells containing character `'0'` cannot belong to the square. Return 0 when there is no all-one square. ```cpp int maximalSquare(vector<vector<char>>& matrix); ``` Quoted rows abbreviate character rows; this is not an integer-cell matrix API. ### Examples ```text Input rows: ["1110","1110","1111"] Output: 9 ``` ```text Input rows: ["01","10"] Output: 1 ``` ### Constraints - Both dimensions are between 1 and 300. - Every cell is character `'0'` or `'1'`.

Overview: Compute maximal all-one square area with rolling side-length summaries and correct character-cell semantics.

Google logo
Google
Source window: 0–3 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

Find the largest square whose cells are all character '1' in a rectangular binary matrix, and return its area. Cells containing character '0' cannot belong to the square. Return 0 when there is no all-one square.

int maximalSquare(vector<vector<char>>& matrix);

Quoted rows abbreviate character rows; this is not an integer-cell matrix API.

Examples

Input rows: ["1110","1110","1111"]
Output: 9
Input rows: ["01","10"]
Output: 1

Constraints

  • Both dimensions are between 1 and 300.
  • Every cell is character '0' or '1' .