Given an array A of size N with numbers from 1 to N in random order, return an array B such that B[i] is equal to the number of elements greater than A[i] to its right in A.
This question is same as this Leetcode quesiton.
Except the fact that here we know that array is permutation of [1..N]. Can we leverage that fact and optimize this? Say to time O(n)?