Practice Brace Expansion II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Interpret expression as a set of lowercase words. A single letter represents the set containing that letter. Braces around a comma-separated list represent the union of the enclosed expressions, removing duplicates. Concatenated expressions represent every concatenation of a word from the first set with a word from the second set. These rules apply recursively to nested expressions. Return the distinct resulting words in sorted order.
Source: Brace Expansion II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
expression = "{a,b}{c,{d,e}}"["ac","ad","ae","bc","bd","be"]
# Example 2
expression = "{{a,z},a{b,c},{ab,z}}"["a","ab","ac","z"]
Constraints
Related LeetCode Problems
Practice more problems similar to Brace Expansion II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.