Limits of integration for range of uniform distribution

Given $\{X_1 , X_2, ... X_n\}$ are random samples from $\text{Uniform}(0,1)$. what is CDF of $R=Y_n - Y_1$ where $Y_1$ and $Y_n$ are the smallest and largest order statistic of the sample respectively.

Define $k\geq 0$.

The joint p.d.f of ($Y_{1}, Y_{n} $) is given as :

$$g(y_1, y_n) = n(n-1)f(y_{1})f(y_n)\left(F(y_n)-F(y_1)\right)^{n-2} $$

\begin{align*} P(R \leq k) &= P(Y_n-Y_1 \leq k) \\ &= \iint\limits_{y_n-y_1 \leq k} g(y_1,y_n) \, dy_1 dy_n\\ &= \int_{-\infty}^{\infty} \int_{y_1}^{y_1 +k} g(y_1,y_n) \, dy_n dy_1\\ &= \int_{-\infty}^{\infty} \int_{y_1}^{y_1 +k} n(n-1)f(y_{1})f(y_n)\left(F(y_n)-F(y_1)\right)^{n-2} \, dy_n dy_1\\ &= n(n-1) \int_{-\infty}^{\infty} f(y_{1}) \int_{0}^{F(y_1+k)-F(y_1)} \phi^{n-2} \, d\phi \,dy_1\\ &= n(n-1) \int_{-\infty}^{\infty} f(y_{1}) \, \frac{\phi^{n-1}}{n-1} \bigg\vert_0^{F(y_1+k)-F(y_1)} \,dy_1\\ &=n\int_{-\infty}^{\infty} f(y_{1}) \, \phi^{n-1} \bigg\vert_0^{F(y_1+k)-F(y_1)} \,dy_1\\ &= n\int_{-\infty}^{\infty} f(y_{1}) \, [F(y_1+k)-F(y_1)]^{n-1} dy_1\\ &=n \int_{0}^{1} f(y_{1}) \, [F(y_1+k)-F(y_1)]^{n-1} dy_1 \end{align*}

I am not sure how to proceed further. In particular, the precise way to decide what the limits should be given $0<k<1$. I saw on other post that the next step is: $$n \int_0^{1-k} k^{} dy_1 + n \int_{1-k}^{1} (1-y_1)^{n-1} dy_1 $$

But I am not seeing the intuition for this. I tried doing $0<y_1 +k< 1$ then to compute the $F(y_1 +k)$ using the definition of uniform distribution. This works for the first part but the second part seems not obvious. It seems I am missing something. Any intuitive explanation or guide will be appreciated.


Setting $x=\min$ and $y=\max$ your joint density function looks like

$$f_{XY}(x,y)=n(n-1)(y-x)^{n-2}\cdot\mathbb{1}_{x<y}$$

using the following transformation

$$\begin{cases} r=y-x \\ t=y \end{cases}\rightarrow\begin{cases} x=t-r \\ y=t \end{cases}$$

the jacobian is $|J|=1$ thus

$$f_{RT}(r,t)=n(n-1)r^{n-2}$$

defined where $0<t-r<1$ that is over a triangle thus by integration

$$f_R(r)=n(n-1)r^{n-2}\int_r^1 dt=n(n-1)r^{n-2}(1-r)$$

We immediately recognize a known distribution

$$R\sim \text{Beta}(n-1;2)$$