Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Count Inversions by l.szyman10
def count_inversion(sequence):
"""
Count inversions in a sequence of numbers
"""
return sum([sorted(sequence[i:]).index(x) for i, x in enumerate(sequence)])
May 11, 2020