$n$ can have 6 possible values based on division algorithm: $6q, 6q+1,..., 6q+5, \exists q \in \mathbb {Z}.$
Need check only the remainder, as will it fall in the class of remainders given as follows:
The remainder of any number mod 6 will fall in the 6 bins: {$0,1, ..., 5$}. Taking the remainder of squares of these will have the values as: $0, 1, 4, 3, 4, 1$ respectively, or the set {$0, 1, 3, 4$}.
So, need find if that the value of $n^2-5 \mod 6 $ will fall in the set. for this just need to take following steps:
(i) check the remainder of $n\mod 6 \implies \{0,1,...,5\}$
(ii) check the remainder of $n^2\mod 6 \implies \{0,1,4,3\}$
(iii) check the remainder of $(n^2-5)\mod 6$. I take that the remainder of $(n^2)\mod 6$ on subtraction by $5$ will simply take the subtraction as follows: {$-5, -4, -1, -2$} $\equiv$ {$1,2,5,4$}.
So, the question reduces to : if any of the four equations are possible:
a) $n^2 = 6$
b) $n^2 = 7$
c) $n^2 = 10$
d) $n^2 = 9$
Only the case (d) is possible, so the value of n for which $n\equiv 3\pmod 6$ are eligible. These are: $n =9$, or in general $9k$, $\forall k \in \mathbb {Z}$.