Bro it depends on the number of unpaired electrons.for that u need to use the orbital sub levels which are required to hold all the electrons
for that first u need to know the atomic number of the element
determine the charge on the atom
and also you need to know some important elements which are frequently asked in exam
u need to have an idea about the electronic configuartion notation
memorize the order of orbitals for example
1s, 2s, 2p, 3s, 3p, 4s, 3d, 4p, 5s, 4d, ............................
and fill the orbitals according to the unpaired electrons