Brace Expansion
A medium-tier problem at 67% community acceptance, tagged with String, Backtracking, Breadth-First Search. Reported in interviews at Niantic and 2 others.
Brace Expansion hits your assessment and you're staring at a string like "a{b,c}d" wondering if you should parse it left-to-right or recursively. You're not alone. This medium-difficulty problem appears in live OAs at Stripe, DoorDash, and Niantic. The trick isn't immediately obvious, and if you blank on whether to use backtracking or BFS, your solve time tanks fast. StealthCoder runs invisibly during your assessment and surfaces a working solution if you hit the wall on this specific pattern.
Companies that ask "Brace Expansion"
Brace Expansion is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderBrace Expansion requires you to generate all possible strings from a template with nested curly braces containing comma-separated choices. The trap is thinking you can solve it with simple regex or a single pass. You need either backtracking to explore each choice recursively, or BFS to level-process expansions, depending on brace nesting depth. Most candidates mishandle the order of operations when braces are nested or stacked. The key insight is that each choice spawns a new branch of the solution tree, and you must generate them in lexicographic order. When you hit this live and forget whether to recurse or queue, StealthCoder gives you a working implementation in seconds, invisible to the proctor.
Pattern tags
You know the problem.
Make sure you actually pass it.
Brace Expansion recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Brace Expansion interview FAQ
Is Brace Expansion really asked at Stripe and DoorDash?+
Yes. It's been reported by candidates from all three top companies listed here: Stripe, DoorDash, and Niantic. Acceptance rate sits at 66%, meaning a solid number of strong candidates get it right, but it's not a gimme. If you're prepping for either company, this pattern is worth drilling.
What's the trick to Brace Expansion I keep missing?+
The trap is thinking you handle all braces in a single pass. You don't. You need to recurse into or iterate through each choice inside braces, building separate strings for each. Backtracking lets you explore branches cleanly. BFS works too if you layer expansions. The 'trick' is recognizing that every brace level spawns multiple output strings, not a filter.
How does this relate to String and Backtracking on the topics list?+
String manipulation is the surface. Backtracking is the engine. You're building a decision tree where each brace choice is a branch point, and you explore every path. If you're comfortable with permutations or combinations via backtracking, Brace Expansion is the same pattern applied to string choices rather than numbers.
Should I use recursion or BFS?+
Both work, but recursion (backtracking) is more intuitive for most people. You recurse into the next brace, collect results, and append each to previous strings. BFS works if you process braces level-by-level using a queue. Start with recursion. If you're blocked at the assessment, a working BFS solution is often faster to code under pressure.
Is this harder than other medium-difficulty string problems?+
It depends on your backtracking comfort. The 66% acceptance rate suggests it's middle-of-the-road for medium problems. If you're solid on recursion and understand how to handle nested structures, it's straightforward. If backtracking isn't in your muscle memory yet, you'll struggle. Either way, the pattern repeats across easier problems, so it's worth learning now.
Want the actual problem statement? View "Brace Expansion" on LeetCode →