Let $$P(x) = \left(1+x+x^2\right)^n = a_0 + a_1x + a_2x^2 + a_3x^3 + \dots$$
The required quantity is the sum of the coefficients of the even powers of $$x$$, namely $$E = a_0 + a_2 + a_4 + \dots$$
For any polynomial, we have the identities:
$$P(1) = a_0 + a_1 + a_2 + a_3 + \dots = E + O$$
$$P(-1) = a_0 - a_1 + a_2 - a_3 + \dots = E - O$$
where $$O$$ denotes the sum of coefficients of the odd powers.
Adding these two equations eliminates $$O$$:
$$E = \frac{P(1) + P(-1)}{2}$$
Compute the two evaluations for our polynomial:
$$P(1) = (1+1+1)^n = 3^n$$
$$P(-1) = (1-1+1)^n = 1^n = 1$$
Hence
$$E = \frac{3^n + 1}{2}$$
According to the question, this sum equals 365:
$$\frac{3^n + 1}{2} = 365 \;\;\Longrightarrow\;\; 3^n + 1 = 730 \;\;\Longrightarrow\;\; 3^n = 729$$
Since $$729 = 3^6$$, we get $$n = 6$$.
Option B which is: 6