for(int x=0;x<col;x++){ if (matrix[0][x]=='1'){ dp[0][x]=1; ret=1; } }
for (int y = 1; y < row; y++) { for (int x = 1; x < col; x++) { if(matrix[y][x]=='0') continue; dp[y][x] = Math.min(dp[y-1][x], Math.min(dp[y-1][x-1], dp[y][x-1]) ) +1; if(dp[y][x]>ret) ret = dp[y][x]; } }