I found this interesting problem here
the problem :
We have an array of integer a[1], a[2], ... , a[N] and a number M.
We take a version of selection sort like this:
for i := 1 to M do
for j := i + 1 to N do
if (a[i] > a[j]) then swap(a[i], a[j])
After the program end, count the number of swap operator in it.
Limitation:
1 <= M <= N <= 10^5
abs(ai) <= 10^9
any idea for the solution please ?
thanks in advance ^_^