FunctionRacerProblemsRace

Expand the Braces

HardStringsPython, JavaScript, TypeScript, Java, C++

pattern is made of lowercase letters, braces and commas, and stands for a set of words:

For example a{b,c{d,e}} stands for ab, acd and ace.

Return every different word pattern stands for, in any order.

Example 1

pattern "s{a,i}t"
returns ["sat","sit"]

The braces stand for a or i, between s and t.

Example 2

pattern "{b,c{a,o}}t"
returns ["bt","cat","cot"]

The outer braces stand for b, or for c followed by a or o. Then comes t.

Example 3

pattern "{a,a}b"
returns ["ab"]

Both choices are the same, so there is only one word.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems