I am having trouble with a probability problem: "Consider a coin which has probability p of coming up heads on a single flip. Suppose that A flips this coin n times and records the sequence of heads and tails and then B flips the same coin n times and records the sequence of heads and tails. Compute (in terms of n and p) the probability that B’s sequence of heads and tails is the same as A’s sequence of heads and tails. Your final answer should not involve any sums. "
At any point in time, the next flip will be independent of the previous toss's result. In any one combinations, if we consider a possibility of x Hs and n-x Ts, then there are nCx * (p^x) * (1-p)^(n-x) combinations of these types. So for a given pattern with x Hs and n-x Ts to occur the Probability is nCx * (p^x) * (1-p)^(n-x). I am stuck at the part where to figure out "given that A shows any pattern with x Hs and n-x Ts, the probability that B shows the same"