I am trying to solve the following probability problem which involves uniform distribution:
An ambulance travels back and forth, at a constant speed, along a road of length L. At a certain moment of time an accident occurs at a point uniformly distributed on the road. (That is, its distance from one of the fixed ends of the road is uniformly distributed over (0, L).) Assuming that the ambulance’s location at the moment of the accident is also uniformly distributed, compute, assuming independence, the distribution of its distance from the accident.
The following is the suggested solution:
$$ \begin{aligned} \text{Let } z &= |X-Y|, \\ \\ F_Z(z) &= P(|X-Y|<z) = P(-z<X-Y<z) \\ &=\int_0^L{P(y-z<X<y+z|Y=y)f_Y(y)}dy \\ &=\int_0^L{P(y-z<X<y+z)f_Y(y)}dy \\ &=\int_0^L{[F_X(y+z)-F_X(y-z)]f_Y(y)}dy \\ &=\int_0^z{\frac{(y+z)}{L}\frac{1}{L}}dy + \int_z^{L-z}{\frac{2z}{L}\frac{1}{L}}dy + \int_{L-z}^L{\frac{L+z-y}{L}\frac{1}{L}}dy \\ &=\cdots \end{aligned} $$
Problem source: here
I don't understand how the solution derived the limits for the sum of 3 integrals in the last step (as shown above). I also do not understand how they derived the terms for the 3 integrals from the second last step. Could someone please explain these to me?