Trains the technique from
LeetCode 1087Brace ExpansionThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A catalogue writes a family of part codes as one template s, built from lowercase letters and from groups wrapped in curly brackets. A group such as {a,c,f} lists its options separated by commas; the options inside one group are single letters, all different from each other, and a group is never written inside another group. A letter outside every bracket appears in the code as it stands, and each group supplies exactly one of its letters.
Return every part code the template allows, in lexicographic order, that is the order a dictionary would list them in.
Example 1
The first group supplies a or b, the letter p is fixed, and the second group supplies c or d. All four codes are listed in dictionary order.
Example 2
The template is one group offering b or a, so the codes are the single letters a and b, listed in dictionary order rather than in the order the template wrote them.
Example 3
The group offers one option, so the template allows the single code q.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def expand(s: str) -> list[str]:public String[] expand(String s)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.