Template Function ADS::countInversions

Function Documentation

template<class T, class C = std::less<>>
long long ADS::countInversions(std::vector<T> &A, C less = C())

the number of inversions of A, which ends sorted, O( n log n )

Post:

A is sorted, with the same items