Brace Expansion

Given a string S containing lowercase letters and non-nested brace groups, expand every brace group into all of its comma-separated alternatives. Return the Cartesian product of the choices sorted in lexicographical order. A literal string with no braces expands to itself.

Examples
Input: "{a,b}c{d,e}f"
Output: ["acdf","acef","bcdf","bcef"]
Hints

Brace Expansion

Given a string `S` containing lowercase letters and non-nested brace groups, expand every brace group into all of its comma-separated alternatives. Return the Cartesian product of the choices sorted in lexicographical order. A literal string with no braces expands to itself.