Tap here to switch tabs
Problem
Submissions

Problem: Brace Expansion

Try to solve the Brace Expansion problem.

Statement

You are given a string s that represents a list of words.

Each position in the generated words can have one or more character choices:

  • If there is only 11 choice, the character appears by itself.

  • If there are multiple choices, they are enclosed within curly brackets and separated by commas, such as "{a,b,c}" representing the choices 'a', 'b', or 'c'.

Expand the string and return all possible words that can be formed, sorted in lexicographical order.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • s consists of curly brackets '{' and '}', commas ',', and lowercase English letters.

  • s is guaranteed to be a valid input.

  • There are no nested curly brackets.

  • All characters inside a pair of consecutive opening and ending curly brackets are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Brace Expansion

Try to solve the Brace Expansion problem.

Statement

You are given a string s that represents a list of words.

Each position in the generated words can have one or more character choices:

  • If there is only 11 choice, the character appears by itself.

  • If there are multiple choices, they are enclosed within curly brackets and separated by commas, such as "{a,b,c}" representing the choices 'a', 'b', or 'c'.

Expand the string and return all possible words that can be formed, sorted in lexicographical order.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • s consists of curly brackets '{' and '}', commas ',', and lowercase English letters.

  • s is guaranteed to be a valid input.

  • There are no nested curly brackets.

  • All characters inside a pair of consecutive opening and ending curly brackets are distinct.