Hi, all!
I have an array a[] size of n. note that a[i] in range of 10^18. n in range of 10^6.
How to calculate cnt[] in O(n)?
Here cnt[i] = number of elements in a[] that is no greater than a[i].
For exmaple, a[] = 3 2 3 1 1 2, size n= 6
then cnt[] = 6 4 6 2 2 4.
Is there any algorithm to do that in O(n)? or in O(nlogn) if we have to sort?