Expected number of tosses to get either $n$ heads or $n$ tails in a row? I have solved the problem for the expected number of tosses to get $n$ heads in a row, which is $2^{n+1} - 2$. To get $n$ heads OR $n$ tails, I think the problem is substantially more difficult, and I can't figure out a way to generalize this for any $n$.
Is there a straightforward approach to generalizing this? The lack of information on this online seems to suggest that it isn't so straightforward.
Suppose the answer to the expected time to  get $n$ heads or $n$ tails was $f(n)$.
Then the expected time to  get $n$ heads would be $2f(n)$  and similarly the the expected time to  get $n$ tails would be $2f(n)$: you try to get one of them and with probability $\frac12$ it is the one you want while with probability $\frac12$ you start again and it is like the expected time to get a single head.
But you already know $2f(n)=2^{n+1}-2$, so $f(n)$ is half this, namely $2^{n}-1$
For $n$ heads, you start with $0$ heads and when you have $k$ heads, there is a 50:50 chance that you change to either $k+1$ heads or to $0$ heads.
For $n$ heads-or-tails, after one toss you definitely have $1$ head-or-tail, and when you have $k$ heads-or-tails, there is a 50:50 chance that you change to either $k+1$ heads-or-tails or to $1$ (other) head-or-tail.
Hence the answer to the second problem for $n$ is the same as the answer to the first problem with $n-1$, plus $1$.

Put differently, replace the original sequence of heads and tails by (the first toss and) XOR results of consecutive tosses (i.e., either $=$ or $\neq$). These occur like coin tosses, i.e., independently and with probability $\frac 12$. Your goal is to collect $n-1$ consecutive &quot;$=$&quot; (after the initial toss).  So again, we arrive at $(2^{n-1}-2)+1$.