left and top of the same dimensions as the input grid to store the number of consecutive 1s to the left and above each cell, respectively.left and top arrays by iterating over the grid and updating the count of consecutive 1s.maxSquare to keep track of the size of the largest square found so far.left and top arrays.1s.maxSquare if the found square is larger than the current maxSquare.maxSquare * maxSquare as the area of the largest square with 1s on its border.