FastPrepFastPrep
Problem Brief

Maximal Square Area

FULLTIMEONSITE INTERVIEW
See Uber online assessment and hiring insights

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 Description

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.

1Example 1

Input
input = "4 5\n10100\n10111\n11111\n10010"
Output
["4"]
Explanation

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

Constraints

Limits and guarantees your solution can rely on.

Use the limits and requirements stated in the prompt.

public String[] solveMaximalSquareArea(String input) {
    // write your code here
}
Input

input

"4 5\n10100\n10111\n11111\n10010"

Output

["4"]

Sign in to submit your solution.