get the number of overlapping intervals, given two lists of intervals
<p>I recently came across an interesting problem:</p>

<p>Given two lists of intervals, find the total number of overlapping intervals from the two lists. </p>

<pre><code>Example

L1: ([1,2][2,3][4,5][6,7])
L2: ([1,5][2,3][4,7][5,7])

[1,5] overlaps [1,2] [2,3] [4,5]
[2,3] overlaps [1,2] [2,3]
[4,7] overlaps [4,5] [6,7]
[5,7] overlaps [4,5] [6,7]

total = 3+2+2+2 = 9
</code></pre>

<p>Obviously the brute force approach works, but it's too slow (I need something better than O(n^2)).</p>

<p>I also fond a similar problem <a href="http://www.geeksforgeeks.org/minimum-number-platforms-required-railwaybus-station/" rel="nofollow">here</a>. But it's not exactly the same...</p>

<p>Any help is appreciated</p>