Let $X$ and $Y$ be independent random variables, uniformly distributed on the interval $[0,1]$. Find the PDF of $X − Y$
This is how I solved it:
\begin{align} f(x) = f(y) = \begin{cases}1 & 0 \leq x \leq 1, 0 \leq y \leq 1\\0 & Otherwise \end{cases} \end{align} \begin{align} f_{Z}(z)=\int_{-\infty}^{\infty} f_{X}(y+z)f_{Y}(y)dy \end{align} now the integrated is $0$ unless $0 \leq y+z \leq 1 (i.e, -z \leq y \leq 1-z)$ and then it is $1$
but I don't know how I can find ranges for $Z$
Almost okay, but more correctly : $$\begin{align} f_X(x) \cdot f_Y(y) &= \begin{cases}1 & 0 \leq x \leq 1, 0 \leq y \leq 1\\0 & \text{Otherwise} \end{cases} \end{align}$$
You find it from the joint support. $0\leq z+y\leq 1, 0\leq y\leq 1 \implies -1\leq z\leq 1$
So your integral is: $$\begin{align}f_Z(z) &= \mathbf 1_{-1\leq z\leq 1}\cdot \int_{\Bbb R} \mathbf 1_{-z\leq y\leq 1-z, 0\leq y\leq 1}\operatorname d y \\[1ex] &= \mathbf 1_{-1\leq z\leq 1}\cdot \int_{\max\{-z,0\}}^{\min\{1-z,1\}} 1\operatorname d y \\[1ex] &= \mathbf 1_{-1\leq z\leq 1}\cdot (\min\{1-z,1\}-\max\{-z,0\}) \\[2ex] &= (1-\lvert z\rvert)\cdot \mathbf 1_{-1\leq z\leq 1} \end{align}$$