title: Find elements in a vector which lie within specified ranges
body: <p>I have a vector of integer elements in sorted. An example is given below:</p>
  
  <pre><code>vector&lt;int&gt; A ={3,4,5,9,20,71,89,92,100,103,109,110,121,172,189,194,198};
  </code></pre>
  
  <p>Now given the following "start" and "end" ranges I want to find out which elements of vector A fall into the start and end ranges.</p>
  
  <pre><code>int startA=4; int endA=8;
  int startB=20; int endB=99;
  int startA=120; int endC=195;
  </code></pre>
  
  <p>For example, </p>
  
  <pre><code>elements lying in range startA and startB are: {4,5}
  elements lying in range startA and startB are: {20,71,89,92}
  elements lying in range startC and startC are: {121,172,189,194}
  </code></pre>
  
  <p>One way to do this is to iterate over all elements of "A" and check whether they lie between the specified ranges. Is there some other more efficient way to find out the elements in the vector satisfying a given range</p>