Let $(X,S,\mu)$ be a measure space. Suppose $\mu(X)<\infty$. Put $E_n=\{$ $x\in X:$ $n-1\leq |f(x)|<n \}$
Then, $f\in \mathcal{L}^p$ if and only if $\sum_{n=1}^{\infty}n^p\mu(E_n)<\infty$.
My attempt:
Notice, $X=\bigcup_{n=1}^{\infty}E_n$. Since $(E_n)_n$ are pairwise disjoint, we deduce by a standard property of measures that $\mu(E_n)<\infty$ for each $n$. As a consequence,
$\int |f|^p d\mu=\sum_{n=1}^{\infty}\int_{E_n}|f|^p d\mu$
Now, observe that for each $n$,
$n^p\chi_{E_n} \geq |f|^p\chi_{E_n}\geq (n-1)^p\chi_{E_n}$
Upon taking integrals, we obtain:
$ \sum_{n=1}^{\infty}(n-1)^p \mu(E_n)\leq\int |f|^p d\mu \leq \sum_{n=1}^{\infty} n^p\mu(E_n)$
So, if $\sum_{n=1}^{\infty}n^p\mu(E_n)<\infty$ then $f\in \mathcal{L}^p$.
Now for the reverse, not that if $\mu(E_n)=0$ for each $n$ then we are done. If there is some $n$ such that $\mu(E_n)=0$ if $f\in \mathcal{L}^p$, then
$\sum_{n=1}^{\infty}(n-1)^p \mu(E_n)<\infty$.
Now the question is how do we determine whether a series coneverges given another one converges? The answer is the $\textbf{limit comparison test}$:
Theorem: Let $\sum_{n=1}^{\infty}a_n$ and $\sum_{n=1}^{\infty}b_n$ be two series such that $a_n\geq 0$ and $b_n>0 0$ for all $n$.
Put $c= \lim_{n\rightarrow \infty}\frac{a_n}{b_n}$.
If $0<c<\infty$ then either both series converge or both series diverge.
To invoke this theorem notice that if for all $n$, $\mu(E_n)=0$ then we are immediately done. So, we may assume that for some n , $\mu(E_n)>0$. If for all $n$, this is the case, then we are immediately done. If only finitely many satisfy this property, then we may disregard the ones with 0 measure. Thus, we may assume for each $n$, $\mu(E_n)>0$. In which case,
the limit comparison test above allows us to deduce that $c=1$. Since $\sum_{n=1}^{\infty}(n-1)^p \mu(E_n)$ converges, so must $\sum_{n=1}^{\infty}n^p \mu(E_n)$.
Following your ideas, observe that
$$\sum_{n=1}^\infty (n-1)^p\mu(E_n)\le \sum_{n=1}^\infty\int_{E_n} |f|^pd\mu \le \sum_{n=1}^\infty n^p\mu(E_n) $$
If $\sum n^p\mu(E_n)<+\infty$, then the integral is also finite and $f\in{\cal L}^p$.
Conversely, If the integral is convergent, then $\sum (n-1)^p\mu(E_n)<+\infty$ and this series have the same bahavior as yours. Indeed, by Ratio test $$\lim_{n\to\infty}\frac{(n+1)^p\mu(E_n)}{n^p\mu(E_n)} =\lim (1+1/n)^p=1.$$