This is Exercise $50$ from Tao's blog note: https://terrytao.wordpress.com/2010/10/16/245a-notes-5-differentiation-theorems/#comments
$(1)$. Give an example of a compact set ${K \subset {\mathbb R}}$ of positive measure such that ${m(K \cap I) < |I|}$ for every interval ${I}$ of positive length. (Hint: first construct an open dense subset of ${[0,1]}$ of measure strictly less than ${1}$.)
$(2)$. Give an example of a measurable set ${E \subset {\mathbb R}}$ such that ${0 < m(E \cap I) < |I|}$ for every interval ${I}$ of positive length. (Hint: first work in a bounded interval, such as ${(-1,2)}$. The complement of the set ${K}$ in the first example is the union of at most countably many open intervals. Now fill in these open intervals and iterate.)
For part $(1)$, consider ${\mathbb Q} \cap (0,1) = \{r_1, r_2, \dots\}$. Let $0 < \varepsilon < 1$ be small enough that $\forall r_n \in {\mathbb Q} \cap (0,1)$, $s_n = (r_n - \frac{\varepsilon}{4^n}, r_n + \frac{\varepsilon}{4^n}) \subset (0,1)$. Let $D = \bigcup_n^\infty s_n$, then $D$ is an open dense subset of ${[0,1]}$ of measure strictly less than ${1}$. Now set $K = [0,1] \setminus D$. Then $K$ is compact, $m(K) > 0$, and contains no interval.
For part $(2)$, it seems that one can reduce to the case where $I$ is bounded, since any interval $I$ contains a bounded subinterval $I'$. Following the hint, any bounded interval like $(-1, 2)$ is contained in $\mathbb{R} \setminus K$, which is open and thus can be expressed as a countable union of disjoint open intervals.
From here, I didn't quite get what is suggested by "fill in these open intervals and iterate". Any further hint on the correct direction to proceed will be appreciated.