Since $E_G \gg k_B T$, we can only use the law of mass action.
But the question offers us another piece of information - we are around $|N_D-N_A| \approx n_i$.
That means that we are near the transition between extrinsic and intrinsic regimes.
However, we also know that dopants energies are quite small such that $E_C-E_D \ll E_G$ and $E_A-E_V \ll E_G$.
That means that we expect $n_i \ll n_D$ and $n_i \ll n_A$ (since both $n_i$ and dopant ionazition depends exponentially of the corresponding energy differences).
Therefore, we can confidently say that $N_D \gg n_D$ and $N_A \gg n_A$ so we esentially recover the dopant ionization condition.
Thus, neglecting $n_D$ and $n_A$ such that they are both 0, the solutions to the charge balance are:
Because the dopants stop being ionized at very low temperatures (see next exercise), we can neglect $n_D$ and $n_A$ in this exercise, just like in the lecture.
Writing $n_e n_h = n_i^2$ and $n_e - n_h = N_D - N_A$ and solving these together, we obtain
$$ n_{e} = \frac{1}{2}(\sqrt{D^2+4n_i^2}+D)$$
$$ n_{h} = \frac{1}{2}(\sqrt{D^2+4n_i^2}-D)$$
where $D = N_D - N_A$ and $n_i=n_{e,intrinsic}=n_{h,intrinsic}$.
where $D = N_D - N_A$.
Note that for N_D = N_A results for intrinsic semiconductors are recovered.
For $n_i \gg |N_D - N_A|$ we recover the intrinsic regime, while the opposite limit gives the extrinsic expressions.