Question from Folland real analysis 6.38 I have been staring at this for hours. I cannot figure out how to prove the following from Folland, problem 6.38. Show that:
$$f \in L^p \iff \sum_{k=-\infty}^{+\infty}2^{kp}\lambda_f(2^k)<\infty$$
Where $\lambda_f(2^k)=\mu \left\{x: |f(x)|>2^k \right\}$. 
Some guidance would be greatly appreciated. Thank you.

Hint: Consider the function $g = \sum_{k\in\mathbb{Z}} 2^k \chi_{\left\{x: |f(x)|>2^k\right\}}$, and show that $|f|\leq g\leq 2|f|$.

Added: in the interest of thoroughness, I'll expound. For any $p\geq 1$ we may define $$g_p = \sum_{k\in\mathbb{Z}} 2^{pk} \chi_{\left\{x: |f(x)|>2^k\right\}},$$
and note that whenever $f(x)\neq 0$, and $n\in\mathbb{Z}$ such that $2^n\leq|f(x)|<2^{n+1}$, then we have
$$g_p(x) = \sum_{m=-n}^\infty\left(\frac{1}{2^p}\right)^{m} = 2^{(n+1)p}\frac{1}{2^p-1},$$
hence (everywhere, including such $x$ as $f(x)=0$)
$$\frac{1}{2^p-1}|f(x)|^p \leq g_p(x) \leq \frac{2^p}{2^p-1}|f(x)|^p.$$
Finally, this implies that
$$f\in L^p\iff g_p\in L^1\iff \sum_{k\in\mathbb{Z}} 2^{pk} \mu(\left\{x: |f(x)|>2^k\right\})<\infty.$$
