title: Find overlapping intervals between two lists
body: <p>Given the two lists below, I want to find all the intervals in <code>overlap_list</code> that fall within each of the intervals in the <code>intervals</code> list.</p>
  <pre><code>intervals = [[0, 100000], [100000, 200000]]
  overlap_list = [[1000, 41095], [61070, 65414], [86384, 124015], [131226, 150523]]
  </code></pre>
  <p>This is my solution:</p>
  <pre><code>for element in overlap_list:
      start = element[0]
      end = element[1]
      for window in intervals:
          if start &gt; window[0] and end &lt; window[1]:
              print(window, start, end)
  </code></pre>
  <p>The problem with this solution is that for each element in the <code>overlap_list</code>, I loop over all the windows in the <code>intervals</code> list every time the loop runs, while if I am already at a larger position, I would know that I won't find an overlap with the first window. Is there a more efficient way to code this problem?</p>
  <p>Thanks!</p>