public void setZeroes(int[][] matrix) {
        // Use two arrays, m denotes the rows that have zeros
        //                 n denotes the columns that have zeros
        int m = matrix.length;
        in n = matrix[0].length;

        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] = col[j] = true;
                }
            }
        }

        //Now fill the zeros 
        for (int i = 0; i < m; ++i) {
            if (row[i]) 
                Arrays.fill(matrix[i], 0);
        }

        for (int j = 0; j < n; ++j) {
            if (col[j]) {
                for (int i = 0; i < m; ++i) {
                    matrix[i][j] = 0;
                }
            }
        }
}