Company: Flipkart
Difficulty: medium
Largest Square of 1s Problem Description Given a binary matrix of dimensions RXC, filled with elements 0 and 1, write a program to find the largest square containing only 1s and print its area. Read the input from STDIN and print the output to STDOUT. Do not print arbitrary strings anywhere in the program, as these contribute to the output and testcases will fail. Constraints 2 <= R, C <= 1000 Input Format The first line of input contains two integers R and C separated by a single white space, where R is the number of rows and C is the number of columns. Next, R lines of input, where each line contains C characters ('0' or '1') representing a row of the binary matrix. There are no spaces between characters on a single line. Output Format Output contains the area of the largest square which has only 1s. Examples Example 1: Input: 4 4 0011 1011 0100 1010 Output: 4 Explanation: R = 4 and C = 4 . The input matrix is given below: 0011 1011 0100 1010 The largest square of 1s is a 2x2 s