title: Count total number pairs of indices in array such that arr[i] < arr[j] and i < j
body: <p>Meant to ask this <a href="https://stackoverflow.com/questions/13791288/count-all-pairs-of-indices-in-array-such-that-arri-arrj">here</a> but since I forgot to mention the condition on the indices, creating a new question. </p>
  
  <p>The question is given an unsorted array, find the total number of pairs of indices <code>i, j</code> such that <code>i &lt; j</code> and <code>arr[i] &lt; arr[j]</code>. Complexity should be linear or as close to it.</p>