content: import java.util.Arrays;
  
  /**
   * @author jzy
   * @GitHub <a href="https://github.com/567jin">567jin</a>
   * @since 2024-03-07 16:09:54
   */
  public class _73_SetZeroes {
      public static void main(String[] args) {
          int[][] matrix = {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}};
          for (int[] ints : matrix) {
              System.out.println(Arrays.toString(ints));
          }
          System.out.println("-------------------------------");
          new _73_SetZeroes().setZeroes(matrix);
          for (int[] ints : matrix) {
              System.out.println(Arrays.toString(ints));
          }
      }
  
      public void setZeroes(int[][] matrix) {
          if (matrix == null || matrix.length == 0 || matrix[0].length == 0) {
              return;
          }
          int m = matrix.length;
          int n = matrix[0].length;
          // 两个变量记录 那一行哪一列需要置为0
          boolean[] row = new boolean[m];
          boolean[] col = new boolean[n];
          for (int i = 0; i < m; i++) {
              for (int j = 0; j < n; j++) {
                  if (matrix[i][j] == 0) {
                      row[i] = true;
                      col[j] = true;
                  }
              }
          }
          // 开始置0
          for (int i = 0; i < m; i++) {
              for (int j = 0; j < n; j++) {
                  if (row[i] || col[j]) {  // 根据标记数组 将矩阵相应位置 置为0
                      matrix[i][j] = 0;
                  }
              }
          }
          
      }
  
  }
  