This question was asked in an interview of a Quantitative finance company.
You have $\textit{n}$ fair coins with either heads or tails facing up arranged in a row.
You play a game in rounds described as follows:
In each round check the number of coins having heads. Let it be $\textit{k}$. Now flip the $\textit{k}^{th}$, i.e., if it is head change it to tail, or if it is tail change it to head.
Continue this game until all the coins facing up are tails.
Find the expected number of flips to get the desired arrangement of coins.
I was using the approach that if I have k heads at any instant:
$E_{k}$ describes the expected number of steps to reach k heads. We need to find the value of $E_0$.
\begin{equation}
E_k=\frac{k}{n}E_{k-1}+\frac{n-k}{n}E_{k+1}
\end{equation}
I don't know whether this approach is right. Please suggest some better methods.
2026-04-18 22:24:41.1776551081