Let $g\in C(\mathbb R, \mathbb R)$ and let $r>0$. Consider the function $$u(x)=\begin{cases} 0 &\mbox{ in } (-r, r)\\ g &\mbox{ in } \mathbb R\setminus (-r, r) \end{cases}$$
Let $s\in (0, 1)$ and let $(-\Delta)^s u$ denotes the fractional laplacian of $u$ (see e.g. https://en.wikipedia.org/wiki/Fractional_Laplacian).
I am trying to understand if the function $u$ solves the problem $$\begin{cases} (-\Delta)^s u =0 &\mbox{ in } (-r, r)\\ u=g &\mbox{ in } \mathbb R\setminus (-r, r) \end{cases}.$$
I would say that $u$ does solve it, but when I wrote that during the last week assignment, it was marked as an error and the lecturer said that I have to justify my writing and prove that it holds (or not).
My argument is that since $u=0$ in $(-r, r)$ hence its fractional laplacian is null and $u=g$ in $\mathbb R\setminus (-r, r)$ by definition. Maybe it is not enough.
Anyone could please help me to prove (or disprove) that?
Since you have accepted an answer that says that your $u$ does solve the desired equation, let me explicitly provide a choice of $g$ for which $(-\Delta)^s u(x) \ne 0$ for $x \in (-r, r)$ to make clear that your solution is incorrect.
I will use the definition of the fractional laplacian given by \begin{align*} (-\Delta)^s u(x) = c_{d,s} \int_{\mathbb{R}} \frac{u(x) - u(y)}{|x-y|^{d + 2s}} dy \end{align*} for a suitable strictly positive constant $c_{d,s}$ which is given explicitly at the wikipedia page you linked.
With your choice of $u$, for $x \in (-r,r)$ we then have \begin{align*} (-\Delta)^s u(x) = c_{d,s} \int_{-\infty}^{-r} \frac{- g(y) }{|x-y|^{d + 2s}} dy + c_{d,s} \int_r^\infty \frac{- g(y) }{|x-y|^{d + 2s}} \end{align*} It's then easy to see that if $g$ is a strictly negative function then for your $u$, $(-\Delta)^s u(x) > 0$ and if $g$ is strictly positive then $(-\Delta)^su(x) < 0$. As an example, consider $g$ given by $g(y) = -1$ for all $y$.
Then \begin{align*} (-\Delta)^s u(x) = c_{d,s} \int_{\mathbb{R} \setminus(-r,r)} {|x-y|^{-d - 2s}} dy > 0. \end{align*}