https://www.codechef.com/LTIME74B/problems/SFRV

In this problem, how should we solve it if the element A[i] can be used more than once?? Pls help!

i think if the element of A[i] can be used more than once then this problem will be converted into sorting the array in increasing order.

And what if we can swap with the same number at max two or three times?

Only once.
It’s clearly stated

I know…i just asked what if the question was framed like that!

in that way you can almost sort the whole array and get the max required answer