FastPrepMaximal Square Area
Problems/Maximal Square Area

Maximal Square Area

Uber logoUber● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.

Problem Given an m x n matrix of characters '0' and '1', find the largest square containing only '1's and return its area.

Input

First line: two integers m n

Next m lines: each is a length-n string containing only 0/1

Output

A single integer: the maximal square area

Constraints 1 <= m, n <= 300

Examples 4 5

10100

10111

11111

10010

Output:

4

2 2

00

Output:

0

Example Input

4 5

10100

10111

11111

10010

Output

4

Function

solveMaximalSquareArea(input: String) → String[]

Complete solveMaximalSquareArea. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.

Examples

Example 1

input = "4 5\n10100\n10111\n11111\n10010"return = ["4"]

The returned string array must match the expected standard output lines for the sample input.

Constraints

  • Use the limits and requirements stated in the prompt.

More Uber problems

  • Worst-Performing Ads by CTR in a Campaign TreePHONE SCREEN · Seen Nov 2026
  • Worst-Performing Ads by CTR in a Campaign TreePHONE SCREEN · Seen Nov 2026
  • Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
All Uber interview questionsSee Uber hiring insights
Saved
class Solution {
    public String[] solveMaximalSquareArea(String input) {
        // write your code here
    }

}
Checking account…