Construct a special measurable functions 
*

*Suppose $A$ is a measurable subset of $[0,1]$, show that there exists a measurable function $f(x)$ on the interval $[0,m(A)/2]$ such that 
$$m([x,f(x)]\cap A)=\frac{1}{2}m(A)$$ for all $x$. I know how to solve this problem.

*Suppose $A,B$ are measurable subsets of $[0,1]$, and $m(A)m(B)>0$. Show that there exists $0\le x<y\le 1$ such that 
$$m([x,y]\cap A)=\frac{1}{2}m(A)$$
and $$m([x,y]\cap B)=\frac{1}{2}m(B).$$
 A: First I would establish a slight variant of your first question: given a measurable $A\subset[0,1]$, fix a real number $\alpha\in(0,1)$ such that $m([0,\alpha]\cap A) = \frac12m(A)$ (and hence $m([\alpha,1]\cap A)=\frac12m(A)$ as well). Then show that there is an increasing measurable function $f(x)$, defined on the interval $[0,\alpha]$ and satisfying $f(0)=\alpha$ and $f(\alpha)=1$, such that $m([x,f(x)]\cap A)$ always equals $\frac12m(A)$. (Showing that it's increasing might or might not be necessary.)
Then, given $A$ and $B$ as in your second question (having measure $0$ is fine even), find $\alpha$ and $f(x)$ for $A$ as in the first question, and $\beta$ and $g(x)$ for $B$ as in the second question. If $\alpha=\beta$ then just choose $[x,y]=[0,\alpha]$. If not, then note that the graphs of $f(x)$ and $g(x)$ "cross each other", since one connects the points $(0,\alpha)$ and $(\alpha,1)$ and the other connects the points $(0,\beta)$ and $(\beta,1)$; just choose $(x,y)$ to be a point where they cross. To make this rigorous: supposing $\alpha<\beta$ say, define $x=\inf\{t\in[0,\alpha]\colon f(x) \ge g(x)\}$ and $y$ to be any real number between $f(x)$ and $g(x)$.
