Hydrogen is at temperature $T$ and helium is at temperature $2T$. The internal energy of both gases is the same. The ratio of number of moles of hydrogen and helium gases is
Internal energy of a gas, $U = nC_VT$
where $n$ is the number of the moles of a gas and $C_v$ is the molar specific heat at constant volume and $T$ is the temperature of the gas.
As hydrogen is a diatomic gas,
$\therefore\left(C_{V}\right)_{H_2} = \frac{5}{2}R$
As helium is a monatomic gas,
$\therefore\left(C_{V}\right)_{He} = \frac{3}{2}R$
According to the question
$U_{H_2} = U_{He} $$\Rightarrow n_{H_2} \times\left(C_{V}\right)_{H_2} \times T_{H_2} $$ = n_{He}\times\left(C_{V}\right)_{He} \times T_{He}$$ \therefore n_{H_2} \times\frac{5}{2}R \times T $$ = n_{He} \times\frac{3}{2}R \times 2T $$ \frac{n_{H_2}}{n_{He}} = \frac{6}{5}$