Yttrium has 39 electrons arranged as 2, 8, 18, 9, 2 across 5 shells, which is why it sits in period 5.
How to write it
Start from the previous noble gas core, written in square brackets, then add the remaining electrons in filling order. For yttrium that gives [Kr] 4d1 5s2.