OP's method is O(N^2).
Quote Originally Posted by GNiewerth
#6
Sort both the scrambled and descrambled word´s letters and compare the sorted words.
This one is good and simpler. 1) Sorting would be of the order of O(NlogN) and 2) comparison would be O(N).
Quote Originally Posted by GNiewerth
#5
Use a hash function that creates an unique hash depending on the input letters (independent of their position). Calculate the hash for both the scrambled and descrambled word and compare both hashes.
This one is even better. With maps, this one would be 1) order of insert into multimap O(logN) and 2) comparison of multimaps O(N).

With unordered_multimap (which is what you are suggesting - hash implementations, right?), 1) order of inserts O(1) (worst case O(N)) and 2) comparison O(N).