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.
This may help, but creating a hashmap, mapping values to indices may help. My bottleneck was in using the default "indexOf" method, but creating a hashmap to do these checks helped speed immensely.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
This may help, but creating a hashmap, mapping values to indices may help. My bottleneck was in using the default "indexOf" method, but creating a hashmap to do these checks helped speed immensely.