title: How to find the minimum value in an array in a given range?
body: <p>We are give 2 arrays, one array is called the original array and other is the corresponding array.</p>
  <p>Example :</p>
  <blockquote>
  <p>a: <code>[5,6,5,7,5,5,5,8,9]</code></p>
  <p>a': <code>[1,2,3,1,2,3,1,2,1]</code></p>
  </blockquote>
  <p>We are given 3 values:
  <code>l</code>,<code>r</code> and <code>x</code></p>
  <p>Let <code>l = 3</code> and <code>r = 7</code>, also <code>x = 5</code>,</p>
  <p>So we check the occurrences of <code>5</code> in the range <code>[3,7]</code> , so
  <code>a[3]</code>, <code>a[5]</code>, <code>a[6]</code>, <code>a[7]</code> are the indices which contain <code>5</code>.</p>
  <p>Now, we check the corresponding array's values, <code>a'[3]</code>, <code>a'[5]</code>, <code>a'[6]</code>, <code>a'[7]</code> which are: <code>3</code>, <code>2</code>, <code>3</code> and <code>1</code>. The minimum of these is <code>1</code> and hence the output will be : <code>1</code>.</p>
  <p>I know the brute-force approach for multiple queries like this, but I'm interested in an efficient approach !</p>