We study the density contrast equations for cold dark matter (CDM) in the cosmological radiation and dark energy (DE) background. We provide a general prescription for the derivation of the aforesaid density contrast equations of the CDM using the metric perturbation technique. In particular, in the early radiation domination, the density contrast equation, the so-called Mészáros equation is derived, considering a four-fluid model, while on the other hand, in the late time DE domination, the “w-Mészáros equation” is derived, using the two-fluid system of CDM and DE. In the first case, we find eight-parameter Lie symmetries, while in the second case we also obtain eight symmetry generators of the “w-Mészáros equation,” each for the values of the equation-of-state parameter (w=-2/3) and (-1). Finding group-invariant solutions using the invariant curve condition for both cases, we have investigated the sub-horizon evolution of density contrasts of the CDM and provided a qualitative study on the nature of evolution of the CDM perturbations. The density contrast of CDM shows no growth during the radiation dominated era, but growth is seen just at the time of matter-radiation equality. The freezing or stagnation of the density contrast of the CDM prior to the matter-radiation equilibrium is due to the rapid expansion of the radiation background at early time, while the decay of the density contrast with increasing scale factor, which results in suppression in the growth of the inhomogeneity, is due to the DE dominated accelerated expansion.