title: Finding if the element exist in a given range
body: <p>I have two arrays <code>A</code> and <code>B</code>. And I have to find the number of elements required by array <code>C</code> to fit into a specific length.<br></p>
  
  <pre><code>Length = B[i]-A[i]
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>A[0] = 1    B[0] = 4
  A[1] = 4    B[1] = 5
  A[2] = 5    B[2] = 9
  A[3] = 8    B[3] = 10
  and 
  C[0] = 4
  C[1] = 6
  C[2] = 7
  C[3] = 10
  C[4] = 2
  </code></pre>
  
  <p>Answer would be <code>4</code>.</p>
  
  <p>Explanation:</p>
  
  <pre><code>C[0] is falling in the range of (A[0],B[0]) and (A[1],B[1])
  C[1] is falling in the range of (A[2],B[2]) 
  C[2] is of no use
  C[3] is falling in the range of (A[3],B[3])
  so the total is 4
  </code></pre>
  
  <p>My approaches:<br>
  <strong>Traditional approach</strong>: Simple looping every element of <code>C</code> in array <code>A</code> and if find in the range set the value of <code>A[i]</code> and <code>B[i]</code> to minus infinity or remove them(for Arraylist).</p>
  
  <ul>
  <li><strong>Time complexity</strong> is an issue so not a good approach.</li>
  </ul>
  
  <p><strong>HashTable</strong>: Storing the value in hash table as <code>A[i]</code> as key and <code>B[i]</code> as value. Then finding the element for a given <code>C[i]</code> and removing the key. I think it is not a good approach <br><br>Please provide me a efficient algorithm for this.</p>