In: Statistics and Probability
Consider successive flips of a coin that always lands on "heads" with probability p, and determine the probability distribution of the first time, after the beginning, that the total number of heads is equal to the total number of tails. Hint: the first time that this occurs is at time 2n can be obtained by first conditioning on the total number of heads in the first 2n trials.
This is based on ballot problem (search online if you want)
Now coming back to original question