public static void propagateZeros(int[][] arr)
    {
        int width = arr.length;
        int height = width == 0 ? 0 : arr[0].length;
        int[] rowsToZero = new int[width];
        int[] colsToZero = new int[height];
        for (int ii = 0; ii < width; ii++) {
            for (int jj = 0; jj < height; jj++) {
                if (arr[ii][jj] == 0) {
                    rowsToZero[ii] = 1;
                    colsToZero[jj] = 1;
                }
            }
        }
        for (int ii = 0; ii < width; ii++) {
            for (int jj = 0; jj < height; jj++) {
                if (rowsToZero[ii] == 1 || colsToZero[jj] == 1) {
                    arr[ii][jj] = 0;
                }
            }
        }
    }