3
int largest1BorderedSquare(vector<vector<int>> &g) {6
int ver[n][m]; // to store lenght of continuous 1's vertically7
int hor[n][m]; // to store lenght of continuous 1's horizontally10
for (int i = n - 1; i >= 0; i--) {11
for (int j = 0; j < m; j++) {16
ver[i][j] = ver[i + 1][j] + 1;22
// fill horizontal table23
for (int i = n - 1; i >= 0; i--) {24
for (int j = m - 1; j >= 0; j--) {29
hor[i][j] = hor[i][j + 1] + 1;35
// Iterate through the all i and j and find best solution37
for (int i = 0; i < n; i++) {38
for (int j = 0; j < m; j++) {39
if (!g[i][j]) continue;41
int k = min(hor[i][j], ver[i][j]);42
for (int p = 1; p < k; p++) {43
int mn = min(hor[i + p][j], ver[i][j + p]);44
if (mn >= p + 1) temp = p + 1;