title: Optimize algorithm for determining qualifying score from a predefined range
body: <p><strong>Problem:</strong><br>
  You are given a list(1-D array) of scores(some numbers).<br>
  You are given two more lists:<br>
  lowerLimits : A list that contains lower limit value(s)<br>
  upperLimits : A list that contains upper limit value(s)  </p>
  
  <p>Your task is to find out how many counts of scores fall within the inclusive range of each (lowerLimit[i], upperLimit[i]) pair.</p>
  
  <p><strong>Example 1:</strong></p>
  
  <pre><code>Inputs:
  scores = [1,3,5,6,8]
  lowerLimits = [2]
  upperLimits = [6]
  Output:[3]
  </code></pre>
  
  <p>Explanation:
  Three elements(3,5 and 6) in scores array, fall inside the inclusive range [2,6]</p>
  
  <p><strong>Example 2:</strong></p>
  
  <pre><code>Inputs:
  scores = [4,8,7]
  lowerLimits = [2,4]
  upperLimits = [8,4]
  Output: [3,1]
  </code></pre>
  
  <p>Explanation:
  All three elements(4,8 and 7) in scores array, fall inside the first inclusive range [2,8] and only one element (4) falls within the inclusive range of [4,4]. So the answer to be returned is the counts array [3,1].</p>
  
  <p><strong>What algorithm have I attempted so far?</strong></p>
  
  <pre><code>1. Iterate through each lowerLimit - upperLimit pair
  2. For this pair check all scores values
  3. Repeat step 1 to 2 for all lowerLimit - upperLimit pairs
  </code></pre>
  
  <p><strong>Python 3 Implementation</strong></p>
  
  <pre><code># utility function
  def jobOffers(scores, lowerLimits, upperLimits):
      answer = []
      for index, item in enumerate(lowerLimits):
          dummy = []
          for score in scores:
              if score &gt;= lowerLimits[index] and score &lt;= upperLimits[index]:
                  dummy.append(score)
          if dummy:
              answer.append(len(dummy))
      return answer
  
  # dummy inputs
  scores = [4,8,7]
  lowerLimits = [2,4]
  upperLimits = [8,4]
  
  print(jobOffers(scores,lowerLimits,upperLimits))
  </code></pre>
  
  <p><strong>Problem:</strong><br>
  I can only pass 3 out of 15 test cases with this brute-force algorithm. In fact, the code times out for about 7 test cases and returns incorrect result for the remaining failed test cases. Unfortunately, the server doesn't provide the list of failed test cases, so I can't accommodate logic for such cases. At present, I'm unable to think of any alternate strategy to tackle this problem. Could </p>