10 red cars, 10 blue cars, 10 green cars are distributed randomly in a line. What is the expected number of times a red car precedes a blue car? We can apply linearity of expectation to this to make it easier. This means we reduce the problem to finding the expectation that the red car i precedes the blue car j. This is just the probability of this event. I'm having trouble computing this probability. I appreciate the help.
We find the expected number of times that a red car immediately precedes a blue car. Imagine that the red cars are labelled $1$ to $10$.

Let $X_i=1$ if red car $i$ immediately precedes a blue car, and let $X_i=0$ otherwise. We want to find the expectation of $X_1+\cdots+X_{10}$. By the linearity of expectation and symmetry this is $10E(X_1)$.

We have $E(X_1)=\Pr(X_1=1)$. For $X_1$ to be $1$, red car $1$ must be in positions $1$ to $29$ (probability $\frac{29}{30}$). Given that it is in one of these positions, the probability there is a blue immediately behind it is $\frac{10}{29}$. Thus $\Pr(X_1=1)=\frac{10}{30}$.
Well, you don't care much about the colors of the cars at this point. In fact, you don't even care about the other cars. In half the cases the red car will be before the blue car, and in the other half it'll be after. By linearity of expectation, you just count the number of pairs of red-blue cars and divide that by $2$ to get your answer.

Hope that helps,