I've tried a bunch of different groupings of the three terms so that I could use the binomial expansion forumula, but I haven't been able to go much further than that. This is an example of what I've tried so far: $$(1+x+x^2)^n=\sum_{n=0}^{\infty} {n \choose k}(1+x)^{n-k}x^{2k} =\sum_{k=0}^{\infty}\sum_{i=0}^{\infty}{n \choose k}{{n-k} \choose i}x^{2k+i}$$
I decided to show this as it has the closest looking coefficient to the expected answer, which states that the coefficient of $x^n$ is $$\sum_{k=0}^{n}{n \choose k}{{n-k} \choose k}$$. I'm assuming I'm taking the wrong approach so I'd appreciate some input.