Find a sequence of integrable functions that converges to 0 almost everywhere and satisfies some other conditions. Here's the statement:

Find a sequence $\{h_n\}$ of functions in $\mathscr{L}^1(\mathbb{R},
 \mathscr{B}(\mathbb{R}), \lambda, \mathbb{R})$ that converges to zero
almost everywhere, but satisfies
$$\limsup_n \int h_n \, d \lambda = +1 \quad \text{ and } \quad
 \liminf_n \int h_n \, d \lambda = -1. $$

Here is what I've done:
Let $\mathbb{N}$ denote the set of positive integers and, for each $n \in \mathbb{N}$, define the function $h_n$ on $\mathbb{R}$ by
$$ h_n(x) =   \left\{
\begin{array}{ll}
      \cos(x) \chi_{\left[2\pi n, 2\pi n + \frac{\pi}{2}\right]}(x) & \text{if } n \in 2\mathbb{N} - 1, \\
      \cos(x) \chi_{\left[2\pi n, 2\pi n + \frac{3\pi}{2}\right]}(x) & \text{if } n \in 2\mathbb{N}. \\
\end{array} 
\right.  $$
Then
$$ \int h_n \, d \lambda =   \left\{
\begin{array}{ll}
      +1 & \text{if } n \in 2\mathbb{N} - 1, \\
      -1 & \text{if } n \in 2\mathbb{N}. \\
\end{array} 
\right.  $$
Thus,
$$\limsup_n \int h_n \, d \lambda = +1 \quad \text{ and } \quad \liminf_n \int h_n \, d \lambda = -1, $$
as desired.
Now, let $x \in \mathbb{R}$ be given. Then we can find a positive integer $N_x$ such that $2\pi n > x$ whenever $n \ge N_x$. This means that
$$x \notin \left[2\pi n, 2\pi n + \frac{\pi}{2}\right] \cup \left[2\pi n, 2\pi n + \frac{3 \pi}{2}\right]$$
whenever $n \ge N_x$; and so $h_n(x) \to 0$ as $n \to \infty$. Since $x \in \mathbb{R}$ is arbitrary, it follows that $\{h_n\}$ converges to zero everywhere (and so, a fortiori, almost everywhere), as desired.
So, it seems that I've proven something stronger than what was called for... which makes me think I've either done something wrong or that my solution isn't "in the spirit of the problem." Whatever the case may be, any comments or suggestions are appreciated.
 A: Your solution is correct. In essence,

*

*you used cosines to encode the flipping between $+1$ and $-1$

*you obtained the (almost) everywhere convergence by allowing the mass to escape to "horizontal infinity".

An alternate solution: you can replace the use of cosines by finding $g_n \to 0$, $\int g_n = 1$，and then using $h_n := (-1)^n g_n$.  And since the question did not ask for e.g. $|h_n(x)|\le 1$, you can replace the use of "horizontal infinity" with "vertical infinity" by using e.g.
$$g_n := n \chi_{[0,1/n]}$$
Everything is satisfied but we only have almost everywhere convergence, and not pointwise convergence due to $g_n(0)\to \infty$. The function is also zero outside of $[0,1]$. In fact, we can still achieve pointwise convergence without leaving $[0,1]$ with the following variant:
$$ {\tilde g}_n:= 2n \chi_{[1/(2n),1/n]}$$
The small movement achieves ${\tilde g}_n(x)\equiv 0$ eventually for each $x$, hence the pointwise convergence.
Your example is continuous, while my $g_n$s are not; this can also be achieved by replacing the rectangular profile of $\chi_{[a,b]}$ with triangles coming from rescaling/translating $\max(0,1-2|x|)$ appropriately. There are of course smooth versions as well.
A: Let
$$h_n=(-1)^n\frac{\chi_{[0,n]}}{n},\,n=1,2,\dots.$$
Then $h_n\to 0$ pointwise everywhere (in fact $h_n\to 0$ uniformly on $\mathbb R$) and $\int_{\mathbb R} h_n =(-1)^n$ for all $n,$ giving the result.
