title: count no. of pairs such that absolute difference is less than K
body: <p>Given an array A of size N, how do I count the number of pairs(<code>A[i]</code>, <code>A[j]</code>) such that the absolute difference between them is less than or equal to K where K is any positive natural number? (<code>i</code>, <code>j&lt;=N</code> and <code>i!=j</code>)</p>
  
  <p>My approach:</p>
  
  <ol>
  <li><p>Sort the array.</p></li>
  <li><p>Create another array that stores the absolute difference between two consecutive numbers.</p></li>
  </ol>
  
  <p>Am I heading in the right direction? If yes, then how do I proceed further?</p>