If $f$ is locally Lipschitz, then for any compact set $K$, $f \mid_K$ is globally Lipschitz This problem has been asked here before. For example, this question Prove that the restriction $f|_K$ of $f$ to $K$ is globally Lipschitz where $K$ is a compact set only treated the continuity of $f$ on $K$ while this question $f \in C^1$ defined on a compact set $K$ is Lipschitz? already assumed $f$ to be $C^1$ function. Although, the latter was close to answering my question but used terms difficult for me to understand. So, in both cases, they have not answered my question. So, here it is

If $f:O\subset \Bbb{R}^n\to\Bbb{R}^m$ is locally Lipschitz, then prove that for any compact set $K$ in $O,$ $f \mid_K$ is Lipschitz such that $\exists \;c\in [x,y]$ such that \begin{align}\Vert f(x)-f(y) \Vert\leq c\Vert x-y \Vert,\;\;\forall\;x,y\in K\end{align}

My efforts
Let $K$ be compact in $O$. Let $x,y\in K$, then by MVT, $\exists \;r\in [x,y]$ such that \begin{align}\Vert f(x)-f(y) \Vert\leq \sup\limits_{r\in [x,y]}\Vert f'(r) \Vert\Vert x-y \Vert\end{align}
\begin{align}\qquad\qquad\qquad\leq \sup\limits_{r\in K}\Vert f'(r) \Vert\Vert x-y \Vert\end{align}
Since $f$ is locally Lipschitz, then it is continuous and since $K$ is compact, then the maximum is reached. So, let 
\begin{align}c= \sup\limits_{r\in K}\Vert f'(r) \Vert\end{align}
Thus, 
\begin{align}\Vert f(x)-f(y) \Vert\leq c\Vert x-y \Vert,\;\;\forall\;x,y\in K\end{align}
Please, can anyone help me check if my proof is correct? If no, alternative proofs will be highly regarded! Thanks!
 A: While I am not a fan of proof by contradiction, it works efficiently here.
Suppose $S(x,y)={\|f(x)-f(y)| \over \|x-y\|}$ is unbounded for $x,y \in K, x \neq y$. Then we can find $x_k, y_k \in K$ such that $S(x_k,y_k) \to \infty$. Since $K$ is compact,
we can assume that $x_k \to x, y_k \to y$. Since $f$ is bounded on $K$, we
must have $x=y$ (otherwise $S(x_k,y_k)$ would not be unbounded). By assumption, $f$ is locally Lipschitz around $x$, hence $S(x_k,y_k) \le L$ for some (finite) $L$, which is a contradiction.

Here is a constructive proof:
Since $f$ is locally Lipschitz, for each $x$ there is some $r_x>0$ and $L_x$ such that $f$ is Lipschitz with rank $L_x$ on $B(x,r_x)$.
Then the sets $B(x, {1 \over 2} r_x)$, $x \in O$ form an open cover of $K$, so
a finite number cover $K$. For convenience, denote these by $B(x_k, {1 \over 2} r_k)$ (instead of
$r_{x_k}$).
Let $M= \sup_{x \in M} \|f(x)\|$, $r= {1 \over 2}\min r_k$,  $L_0 = {2M \over r}$
and $L= \max (L_0, L_k)$. Then $L$ is a Lipschitz constant for $f$ on $K$.
To see this, pick $x,y \in K$. If $\|x-y\| \ge r$ then we see that ${ \|f(x)-f(y) \| \over \|x - y \|} \le {2M \over r} = L_0 \le L$. If $\|x-y\| < r$, then for some $x_k$ we have $x \in B(x_k, {1 \over 2} r_k)$. Then $y \in B(x_k, r_k)$ and
so $\|f(x)-f(y) \| \le L_k \|x - y \| \le L \|x - y \|$.
A: By our assumption, $\forall x \in O$, there is a open neighbourhood of $x$, $U_x$,  and $c \in \mathbb{R}$ such that
$$||f(y) - f(z)|| \leq c_x ||y-z|| \quad \forall y,z \in U_x.$$
(Thanks to @copper.hat)
Let $K \subset O$ be compact, then it is the finite union of compact connected $J_ks $, and observe that $S = \{U_x\}_{x\in K}$ is an open cover for $K$, but since $K$ is compact, we can cover with a finite subset of $S$, namely $\{U_x\}_{x \in J}$ for some finite $J \subset K$.
Now, for each $k$, define
$$c_k = max\{c_x| x \in J_k\},$$
and 
$$c = max\{c_k\},$$
hence $f|_K$ is Lipschitz on $K$ with Lipschitz constant $c$.
