Generalized abbreviations
Given a word of lowercase letters (length 0..15), a generalized abbreviation replaces any set of non-overlapping, non-adjacent runs of characters with the count of characters in that run (e.g. 'word' can become 'w1d', '2r1', '4', etc.). Return all distinct generalized abbreviations of the word, sorted ascending. There are exactly 2^len(word) of them.
Implement
generate_abbreviations(word: str) → list[str]Examples
in
["word"]out["1o1d","1o2","1or1","1ord","2r1","2rd","3d","4","w1r1","w1rd","w2d","w3","wo1d","wo2","wor1","word"]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
["word"]["1o1d","1o2","1or1","1ord","2r1","2rd","3d","4","w1r1","w1rd","w2d","w3","wo1d","wo2","wor1","word"]not run yetsample