Let $f: Y \to \mathbb{R}$ be a $k$-lipschitz function with $Y \subset \mathbb{R}$. Prove that there is $g: \mathbb{R} \to \mathbb{R}$ $k$-lipschitz such that $g\mid_{Y} = f$.
Book's hint: First, suppose $f$ bounded and take $\displaystyle g(x) = \inf_{y \in Y}\{f(y) + k|x-y|\}$.
Probably is easy, but I'm stuck to prove that $g$ is $k$-lipschitz. I'm tying to get $$|g(a) - g(b)| \leq |k|a-y| + k|b-y||.$$
$f(y)+k|a-y| \leq f(y)+k|b-y| +k|a-b|$ by triangle inequality. Taking infimum over $y$ we get $g(a) \leq g(b)+k|a-b|$. Interchange $a$ and $b$ to get $g(b) \leq g(a)+k|a-b|$. Hence $|g(a)-g(b)| \leq k|a-b|$.