Consider $y'' + 2y = f(t), y(0)=y(L)$
$$f(t) = \begin{cases}0 \quad 0<t<L/4 \\ 1 \quad L/4<t<3L/4 \\ 0 \quad 3L/4 < t < L \end{cases}$$
Suppose that we can wrtie $f(t)$ and $y(t)$ using the infinite sums
$$f(t)= \sum_{n=1}^\infty a_n sin (n \pi t)/L $$
$$y(t)= \sum_{n=1}^\infty c_n sin (n \pi t)/L $$
Find $c_n$ in terms of $a_n$, then use the formula
$$a_n= \frac{2}L\sum_0^L f(t) sin \frac{(n \pi t)}L dt$$
to compute $a_n$. Then compute $c_n$ and write $y(t)$ as an infinite sum.
HINT: Substituting the series Expansion for $y$ into the left Hand side of your differential equation, you have:
$\sum_{k=0}^\infty c_k (1-k^2 \pi^2) sin(\frac{\pi k t}{L}) = f(t) = \sum_{k=0}^\infty a_k sin(\frac{\pi k t}{L})$.
Now compare coefficients on both sides of the equation and you get $c_k$ in dependence on $a_k$.
HINT 2: $a_k= \frac{1}{L} \int_0^{2L}f(t)sin(\frac{\pi k t}{L}) dt$. See also