I want to find the fastest way to find the number of elements which are smaller/greater than each element in an array.
For example : Array is [5, 6, 8, 2, 4]. Considering first element, no of elements smaller than it is 2.
The best I could make myself was that each element be compared with the rest of the array elements but it takes a long time for large arrays with number of entries approx 10^5.
if( i!=j && (ar[i]>ar[j]) )