Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
1-liner + imports: O(n²) but faster than with "for" solution in Clear category for Count Inversions by Phil15
from itertools import combinations, starmap
from operator import gt
def count_inversion(seq): return sum(starmap(gt, combinations(seq, 2)))
Nov. 4, 2020
Comments: