Characterization of some affine varieties