Physics

$n_{e}n_{h}=n_{i}$

For intrinsic semiconductors, $n_{e}=n_{h}$

For n-type semiconductors, $n_{e}≈N_{D}$

For p-type semiconductors, $n_{h}≈N_{A}$

For extrinsic semiconductors where approximation is not valid, electrical neutrality must be used along with mass action law.

$n_{e}n_{h}=n_{i}$

& $N_{D}+n_{h}=N_{A}+n_{e}$

We have two equations and two variables and hence, the problems can be solved.