Q. How many strings in {0,1,2,3} have an even number of 1's.
The answer provided uses the recurrence relation $a_{n+1} = 3a_n + (4^n - a_n)$.
The hint given was that consider the last string of length $n+1$ is :
$0$ - Number of strings that can proceed is $a_n$.
I'm assuming that $a_n$ is the number of legal strings that can follow $0$.
So if there was a string $02123210$, since this string has an even number of ones ($a_n$), then $a_n$ strings can proceed the previous string.
Then it would be the same for $2,3$ resulting in the $3a_n$. I don't know however how the $(4^n-a_n)$ came about.
I've tried looking at What is the recurrence relation in this problem?. Since it looks similar to this problem.