Expected winning amounts for $2$ players with different number of sided dice The following is an interview question. 

Given $2$ fair dice. My dice consists of $20$ sides with number from $1$ to $20$. The other player has a  $30$-sided die with numbers from $1$ to $30$. We both flip our own die. If my number is bigger, then the other player gave me my number of dollars and vice versa. But if we got the same number, I will pay the other player the number of dollars. What is the expected value of my winning or lost?

My attempt:
Let $X$ and $Y$ be the score obtained by my die and my opponent respectively.
Therefore, for each $2\leq i\leq 20,$
$$P(I \text{ win } i \text{ amount}) = P(Y<i)\cdot P(X=i) = \frac{(i-1)\times 1}{30\times 20}.$$
On the other hand, for each $-30\leq j\leq -1,$ we have 
$$P(I \text{ lose } j \text{ amount}) = P(X=j)P(Y\geq j) = \frac{1}{20} \frac{30-j+1}{30}$$
It follows that my expected wining amounts is 
$$-\sum_{j=-30}^{-1} j P(I \text{ lose } j \text{ amount}) + \sum_{i=2}^{30} i P(I \text{ win } i \text{ amount}).$$
I am not sure whether I am on the right track.
 A: A simpler way of getting the same answer is as follows (again I assume $m>n$ are the two sizes of dice, with yours smaller).


*

*If your opponent rolls higher than $n$, (probability $\frac{m-n}{m}$), you lose the amount he rolls. This is uniform between $n+1$ and $m$, so on average it is $\frac{n+1+m}{2}$. So this gives a contribution of $-\frac{(m-n)(n+m+1)}{2m}=-\frac{m^2-n^2+m-n}{2m}$.

*If you both roll different numbers which are $n$ or below (probability $\frac{n-1}{m}$) then it is totally symmetrical so your expected win/loss is $0$.

*If you both roll the same number (probability $\frac{1}{m}$), then you lose however much that number is; on average it is $\frac{1+n}{2}$. So this contributes $-\frac{1+n}{2m}$.
Your total expectation is therefore $-\frac{m^2-n^2+m+1}{2m}$, which is the same as Math1000's result.
(This also gives you a quick way to get the answer if you have the larger die, but still pay your opponent when the rolls are equal: just make the first term positive before adding them. Here $m$ is now the number of sides on your die since we assume $m>n$.)
A: More generally assume that your die has $n$ sides and your oppponent's die has $m$ sides. Let $X$, $Y$ be the score obtained by you and your opponent, respectively. Then your winnings are $W := X\mathsf 1_{\{X>Y\}} - Y\mathsf 1_{\{X\leqslant Y\}}$, and so for each $k\in\{2,3,\ldots n\}$ we have
$$
\mathbb P(W = k) = \mathbb P(X\mathsf 1_{\{X>Y\}} - Y\mathsf 1_{\{X\leqslant Y\}} = k) = \mathbb P(X=k)\mathbb P(k>Y) =\begin{cases}
 \frac 1n\cdot\frac{k-1}m = \frac{k-1}{nm},& k\leqslant m\\
\frac1n\cdot\frac mm = \frac1n ,& k>m\\
\end{cases}
$$
Similarly, for $k\in\{-1,-2,\ldots,-m\}$ we have
$$
\mathbb P(W=k) = \mathbb P(Y = |k|)\mathbb P(X\leqslant |k|) = 
\begin{cases}
\frac1m\cdot\frac{|k|}n = \frac{|k|}{mn},& |k|\leqslant n\\
\frac1m\cdot\frac nn = \frac1m,& |k|>n.
\end{cases}
$$
Hence for $m>n$ (as in the original problem), we have
\begin{align}
\mathbb E[W] &= \sum_{k\in\mathbb Z}k\cdot \mathbb P(W=k)\\
&= \sum_{k=2}^n k\cdot\frac{k-1}{nm} - \left(\sum_{k=1}^{n} k\cdot \frac{k}{mn}+\sum_{k=n+1}^{m} k\cdot\frac1m\right)\\
&= \frac{(n-1) (n+1)}{3 m} - \left(\frac{(n+1) (2 n+1)}{6 m} + \frac{(m-n) (m+n+1)}{2 m} \right)\\
&= \frac{(n+1)(n-1)-m(m+1)}{2 m}.
\end{align}
For $n=20$, $m=30$ we have $\mathbb E[W] = -\frac{177}{20}$.
A: Since you're taking $j$  as a negative then I think it must be $$\sum_{j=-30}^{-1} j P(\text{I  lose $j$ amount}) + \sum_{i=2}^{30} i P(\text{I win $i$ amount})$$
Or you may write $$\sum_{\substack{i=-30 \\ i\neq 0,1}}^{20} i P(\text{I get $i$ amount})$$
Where "get" may be pay or earn.
A: Note that the probability of losing $j$ should be:
$$P(I \, lose \, j \, amount) = P(Y=j)P(X\leq j) = \frac{1}{30} \cdot \frac{j}{20}$$
You have a conflict in the signs of $j$. You should have:
$$-\sum_{j=1}^{30} j P(I \, lose \, j \, amount) + \sum_{i=2}^{30} i P(I \, win \, i \, amount)=\\
\sum_{i=2}^{20} i\cdot \frac{(i-1)\times 1}{30\times 20}-
\sum_{j=1}^{20}j\cdot \frac{1}{30}\cdot  \frac{j}{20}-\sum_{j=21}^{30}j\cdot \frac{1}{30}=-8.85.$$
