Firstly, note that if $n \ge 10$, then $n^3 \ge 10n^2$ so $n^3$ will have at least one more digit than $n^2$.
For all $n< 10$, we have $n^2< 100$, so $n^2$ has either 1 or 2 digits, but $n^3$ has 3 digits for $n> 4$ since $5^3 = 125$, so we need only consider $n = 1, 2, 3$ or $4$.
For $n=1$ and $2$, $n^2$ and $n^3$ both have one digit; for $n = 4, n^2 = 16$ and $n^3 = 64$ both have two digits.
However for $n=3, n^2=9$ has one digit while $n^3 = 27$ has two digits.
So 1, 2 and 4 are the only integers with the desired property.
This problem is taken from the UKMT Mathematical Challenges.