Hello everyone,

Can someone help me how to approach this problem?

Thanks in advance

Hello everyone,

Can someone help me how to approach this problem?

Thanks in advance

find number of inversions of an array by making 0 or 1 swaps

- count total inversions
- then choose all pairs of indices such that i<j and a[i]>a[j]
- if you swap them, inversion count=old-1-2*(number of indices k in (i,j) such that a[j]<a[k]<a[i])
- find the minimum value over all pairs, thatâ€™s your answer

help me in mine question too.