Code RoomGeneralized abbreviations
MediumPrep Room Coding #1164

Generalized abbreviations

CodingAlgorithms & data structuresMid–Senior~25 min

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
InputExpectedGot
["a"]["1","a"]not run yetsample