Exclude overlaping intervals
<p>I have two lists of intervals. I would like to remove all times from list1 that already exists in list2.
Example:
List1:</p>

<blockquote>
  <p>[(0,10),(15,20)]</p>
</blockquote>

<p>List2:</p>

<blockquote>
  <p>[(2,3),(5,6)]</p>
</blockquote>

<p>Output:</p>

<blockquote>
  <p>[(0,2),(3,5),(6,10),(15,20)]</p>
</blockquote>

<p>Any hints?</p>

<p>Tried to remove one interval at the time but it seems like I need to take a different approach:</p>

<pre><code>public List&lt;Interval&gt; removeOneTime(Interval interval, Interval remove){
    List&lt;Interval&gt; removed = new LinkedList&lt;Interval&gt;();
    Interval overlap = interval.getOverlap(remove);
    if(overlap.getLength() &gt; 0){
        List&lt;Interval&gt; rms = interval.remove(overlap);
        removed.addAll(rms);
    }
    return removed;
}
</code></pre>
