We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here's a python3 solution that does not assume consecutive values but does assume that values aren't repeated. None of the test cases time out because it looks up indexes to swap using a hash table instead of the list.index method.
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
Here's a python3 solution that does not assume consecutive values but does assume that values aren't repeated. None of the test cases time out because it looks up indexes to swap using a hash table instead of the list.index method.