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.
You could translate the logic more directly by using .utf8 on a string to get the ASCII codes, subtracting the ASCII value of 'a' (97), and using that to index an array of size 26 representing the letters and their counts (like the C/C++ examples posted here). It's possible that using the map and indexing it with strings is more expensive than doing that.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Anagram
You are viewing a single comment's thread. Return to all comments →
You could translate the logic more directly by using .utf8 on a string to get the ASCII codes, subtracting the ASCII value of 'a' (97), and using that to index an array of size 26 representing the letters and their counts (like the C/C++ examples posted here). It's possible that using the map and indexing it with strings is more expensive than doing that.