SPOILER
p = probability of heads
1 - p = probability of tails.
flip the coin twice:
head head = p^2
head tail/tail head = 2p(1-p)
tail tail = (1 - p)^2
Notice the two in the middle there. We can just say head tail = Heads and Tail Heads = Tails. If we get HH or PP, just do it again.
Ok, now call the above procedure, our "randomization algorithm"
we can calculate the expected running time -- our algorithm succeeds with probability 2p(1-p). The number of trials we need to run our algorithm for is a geometric random variable. Thus, the expected running time is 1/(2p(1-p)).