Find the coefficient of x3 in the expansion of (1+x+x2)5
(1+x+x2)5=∑r1+r2+r3=55!r1!×r2!×r3!×(1)r1×(x)r2(x2)r3
We want r2+2r3=3(power of x=3)
The values (r1,r2,r3) can take are (3,1,1) and (2,3,0)
So the coefficient is the sum of 5!3!×1!×1!+5!2!×3!×0!=20+10=30