Code Room
CodingMediumcod-g358
Subject RecursionLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.