title: How to check if an integer value is in a given array of ranges and which array element
body: <p>Got a json file which loads some configurations array as below :</p>
  <p>configs.json</p>
  <pre><code>[
    {
      &quot;category&quot;:&quot;A&quot;,
      &quot;scoreMargins&quot; : [[12], [9,11], [7,9], [5,6], [3,4]]
    },
    {
      &quot;category&quot;:&quot;B&quot;,
      &quot;scoreMargins&quot; : [[3,4], [5,6], [7,8], [9,10], [11, 12]]
    }
  ]
  </code></pre>
  <p>The <code>scoreMargins</code> are not in one exact format, so its de-serialized as an object at the moment. But number of ranges(or single value) are always 5.</p>
  <p>CalculationValues.java</p>
  <pre><code> public class StressTestCategoryCalculationValues {
     private String category;
     private Object scoreMargins;
   }
  </code></pre>
  <p>service :</p>
  <pre><code>List&lt;CalculationValues&gt; values = mapper.readValue(CalculationValues.class.getResourceAsStream('configs.json'),
              mapper.getTypeFactory().constructCollectionType(List.class, CalculationValues.class));
  
  Optional&lt;CalculationValues&gt; configA = values.stream()
              .filter(p -&gt; p.getCategory().equals(&quot;A&quot;))
              .findFirst();
  
  int sumA = xx;
  if (configA.isPresent()) {
      // logic
  }
  </code></pre>
  <p>I want to get which <code>scoreMargins</code> array element holds the range that <code>sumA</code> falls into..</p>
  <p>Ex :</p>
  <pre><code>&quot;scoreMargins&quot; : [[3,4], [5,8], [8,11], [11,12], [12, 13]], 
  
   sumA = 7, result ??
  
   Desired result =  2 (3rd element)
  </code></pre>
  <p>What would be the easiest approach to do this?</p>