First  learn this group of subshell
s sp sp sdp sdp sfdp sfdp 
Value of n for
S = 1 to 7 (n)
P= 2 to 7. (n)
d= 3to 6.  (n-1)
f = 4 to 5. (n-2)
So, 1s   2s 2p   3s 3p   4s 3d 4p   5s 4d 5p                     6s 4f 5d 6p  7s 5f 6d 7p
Electron distribution for
S= 1to 2
P= 1to 6
d= 1to 10
f =1to 14

Example