Solution in C Using Marker

void setZeroes(int** A, int n11, int n12) {
    int i,j; // iterators
    
    for (i=0; i<n11; i++)
        for (j=0; j<n12; j++)
            if (A[i][j] == 0) {
                for(j=0; j<n12; j++)
                    if (A[i][j] != 0)
                        A[i][j] = -1; // for rows, mark nonzero by -1, so that
                                      //  original zeroes are not lost.
                break;
            }
            
    for (j=0; j<n12; j++)
        for (i=0; i<n11; i++)
            if (A[i][j] == 0) {
                for (i=0; i<n11; i++)
                    if (A[i][j] != 0)
                        A[i][j] = -1; // same for cols
                break;
            }
            
    for (i=0; i<n11; i++)
        for (j=0; j<n12; j++)
            if (A[i][j] == -1) // reset marked ones to 0
                A[i][j] = 0;
}
Click here to start solving coding interview questions