Find the inverse Z transform:
I have done the solution but my answer does not match with the one given in the textbook. What I may have done wrong?
HINT: Your partial fraction expansion is wrong; you should always check it by recombining the factors. The correct expansion is
$$X(z)=\frac{z^{-1}-\frac12}{\left(1-\frac12 z^{-1}\right)^2}=\frac{\frac32}{\left(1-\frac12 z^{-1}\right)^2}-\frac{2}{\left(1-\frac12 z^{-1}\right)}\tag{1}$$
You should try to derive this result yourself.
BUT: note that you don't even need partial fractions here because if you know (or look up) the $\mathcal{Z}$-transform correspondence
$$\frac{az^{-1}}{\left(1-a z^{-1}\right)^2}\Longleftrightarrow na^nu[n]\tag{2}$$
then you can directly apply it by writing $X(z)$ as
$$X(z)=2\frac{\frac12z^{-1}}{{\left(1-\frac12 z^{-1}\right)^2}}-z\frac{\frac12z^{-1}}{{\left(1-\frac12 z^{-1}\right)^2}}\tag{3}$$
Finally, note that the given result is wrong. It should be
$$x[n]=2n\left(\frac12\right)^nu[n]-(n+1)\left(\frac12\right)^{n+1}u[n+1]\tag{4}$$