Compute lebesgue measure of set of intervals
You can solve this in $O(n \log n)$ time.  Here is an algorithm.  Sort the intervals by their left endpoint ($x$-value), in increasing value.  At each stage, if the first interval is disjoint from the second interval, remove the first interval and add its width to the running total so far.  If they're not disjoint, replace the first two intervals by their union.