title: how to overlap intervals efficiently
body: <p>I require your help, I have a problem (see picture), I have let say two arrays and each of this array contains intervals with different length and real values and I need to find out how I'm gone overlap this intervals efficiently.</p>
  
  <p>I'm open to ideas, or paper theory or concret algorithms which will let me find a way out!
  I'm guessing about to transform this somehow in waves and overlap them.</p>
  
  <p>Its very important, its for my thesis.</p>
  
  <p>as an example, here in numbers to explain it better:</p>
  
  <ol>
  <li>Array: 1-2, 5-7, 9-12</li>
  <li>Array: 3-4, 5-6, 13-17</li>
  </ol>
  
  <p>The result will be then one single array containing the new intervals.</p>
  
  <p>second interval (Array one and two) are overlapped.</p>
  
  <p>result Array: 1-2, 3-4, 5-7, 9-12, 13-17 </p>
  
  <p>I'm thinking about "interval tree", but its not sufficent how I'm gone merge them.</p>
  
  <p><img src="https://i.stack.imgur.com/hJk6F.png" alt="picture"></p>
  
  <p>Thanks in advance!</p>