title: Difference of elements of 1 unsorted array within given interval
body: <p>Let as assume that we have an unsorted array which is composed of integers.We also have 2 given integers ,L and M. Our task is to compute the number of all pairs of (i,j) that hold the following property : L&lt;=A[j]-A[i]&lt;=M. </p>
  
  <p>Apart from the obvious brute force algorithm that checks all possible pairs ( O(n^2) complexity ) ,is there a faster way to solve this problem?</p>