The Unique Word Abbreviation interview question involves a specific way to abbreviate words: take the first letter, the number of characters in between, and the last letter (e.g., "localization" becomes "l10n"). You are given a dictionary of words and then asked to check if a new word's abbreviation is "unique" relative to that dictionary. An abbreviation is unique if no other word in the dictionary has the same abbreviation, or if only the word itself (if it's in the dictionary) has that abbreviation.
Companies like Meta and Google use the Unique Word Abbreviation coding problem to test a candidate's ability to design a data structure that handles ambiguous requirements. It’s not just about the algorithm; it’s about understanding the specific, slightly counter-intuitive rules for what makes an abbreviation "unique." It evaluates your ability to use Hash Tables for efficient lookup.
The primary Array, Hash Table, Design, String interview pattern is to pre-process the dictionary into a Map. The keys are the abbreviations, and the values can be a Set of the original words that produced that abbreviation. To check if a word is unique:
Dictionary: ["door", "deer", "cake"].
The most frequent error is misunderstanding the "unique" rule—specifically, that if a word is in the dictionary, it doesn't "conflict" with itself. Another mistake is not handling words shorter than 3 characters correctly (though the rules usually still apply, e.g., "it" becomes "i0t" or just "it").
When designing a system or class, always clarify the edge cases for "uniqueness" or "equality." This problem is more about logical precision and efficient mapping than complex mathematical algorithms.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Design SQL | Medium | Solve | |
| Shortest Word Distance II | Medium | Solve | |
| Design Spreadsheet | Medium | Solve | |
| Design a Todo List | Medium | Solve | |
| Apply Discount Every n Orders | Medium | Solve |