Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Count Inversions by tokyoamado
def count_inversion(sequence):
if len(sequence) < 2:
return 0
else:
head = sequence[0]
tail = sequence[1:]
return len([x for x in tail if x < head]) + count_inversion(tail)
Oct. 27, 2017
Comments: