amreen
1
Hello everyone,
Can someone help me how to approach this problem?
Thanks in advance
tamo11
2
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
hard(very) version
help me in mine question too.