I've been asked this question in a real interview and the followup was that how to achieve minimum swaps. I did some tricks to improve my algorithm for several times and in the end he could not come up with a counterexample. But still he did not seem to be satisfied. Anyone has any ideas?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.