A permutation map groups dictionary words by a key formed by sorting their letters. Words with the same sorted representation are stored together, so valid permutations can be retrieved without generating every possible rearrangement. section 5.3.2
The map specializes an associative map from String keys to lists of strings. Its operations sort the supplied key before delegating to the underlying map, keeping insertion, lookup, membership, alteration, and deletion consistent. section 5.3.2
Build a permutation map by:
- Sorting each input word when it becomes a key. section 5.3.2
Dictionary lookup
Given ["traces", "reacts", "crates", "caster", "tool", "loot", "cat"], the key "acerst" stores ["caster", "crates", "reacts", "traces"]. Looking up "reacts" returns that group, while looking up "tool" returns ["loot", "tool"]. section 5.3.3
A permutation map supports word-ladder construction by finding dictionary words formed after adding, removing, or changing letters. Sorting on lookup means the new letter can be added anywhere, and the removed letter need not be positionally tracked. section 5.4
