Count the number of pairs (i,j) where i<j but lst[i]>lst[j]. Example: [2,4,1,3,5] => 3
Implement this function:
def count_inversions(lst: list) -> int:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: lst.
Input
[2, 4, 1, 3, 5]
Output
3