This is exercise 1.7.4 in Norris' Markov Chains textbook. I'm having difficulty calculating a simple looking expectation.
Let $(X_n)_{n\geq0}$ be a simple random walk on $\mathbb{Z}$ with transition probabilities $p_{i,i-1}=q where $p+q=1$ and $q>0$. Let $\gamma^0_i=\mathbb{E}_0(\sum_{n=0}^{T_0-1}1_{\{X_n=i\}})$, that is the expected time spent in $i$ between visits to $0$. Find $\gamma^0_i$. I've tried conditioning on $T_0$ but it led to a sum of probabilities that I found tough to evaluate. I've also tried to analyse it as a random walk on $\mathbb{Z_{\geq0}}$ to hopefully make use of the hitting probabilities but got nowhere. Any hints? (There is a second part to this question using textbook results that suggest that $\gamma^0_i=(p/q)^i$ for $i \leq0$ and $\gamma^0_i=1$ for $i\geq0$, if I calculated it correctly.)