I love this one best. Thanks @qswawrq

public int[][] updateMatrix(int[][] matrix) {
int row = matrix.length, col = matrix[0].length;
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (matrix[i][j] == 1) {
matrix[i][j] = Integer.MAX_VALUE;
if (i - 1 >= 0 && matrix[i - 1][j] != Integer.MAX_VALUE)
matrix[i][j] = Math.min(matrix[i][j], 1 + matrix[i - 1][j]);
if (j - 1 >= 0 && matrix[i][j - 1] != Integer.MAX_VALUE)
matrix[i][j] = Math.min(matrix[i][j], 1 + matrix[i][j - 1]);
}
}
}
for (int i = row - 1; i >= 0; i--) {
for (int j = col - 1; j >= 0; j--) {
if (i + 1 < row && matrix[i + 1][j] != Integer.MAX_VALUE)
matrix[i][j] = Math.min(matrix[i][j], 1 + matrix[i + 1][j]);
if (j + 1 < col && matrix[i][j + 1] != Integer.MAX_VALUE)
matrix[i][j] = Math.min(matrix[i][j], 1 + matrix[i][j + 1]);
}
}
return matrix;
}