Permutation `P = [a1, a2, ... , aN]` of the first `N` natural numbers can be represented by a list of [inversions](https://en.wikipedia.org/wiki/Inversion_%28discrete_mathematics%29) `I = [i1, i2, ... , iN]`, where `iK` tells us how many numbers that are greater than `K` can be found before `K` in the permutation `P`.

Example: if `P = [3, 1, 4, 2]`, then `I = [1, 2, 0, 0]` (3 is placed 1, 3 and 4 are placed before 2, whereas 3 and 4 are not preceded by any bigger number).

There is an obvious algorithm that converts a permutation from standard to inversion form and runs in `O(N^2)` (we just follow the definition and count). The same holds for the inverse conversion (which is slightly less straight forward).

> 
> Is there an algorithm that has lower time complexity?
> 
> 
>