Generalized abbreviations
A word's generalized abbreviation replaces any number of non-overlapping, non-adjacent groups of consecutive characters by the count of characters removed. Given a word, return ALL of its generalized abbreviations. For example 'word' yields forms like 'word', '1ord', 'w1rd', '4', '2rd', etc. Return them sorted lexicographically. The word has at most 12 lowercase letters.
Implement
generate_abbreviations(word: str) → list[str]Examples
in
["a"]out["1","a"]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 25 min
solution.py
InputExpectedGot
["a"]["1","a"]not run yetsample