The Parentheses Factory
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
A template engine checks its output by enumerating every legal bracket nesting it could emit. Given a non-negative integer `n`, return every well-formed string built from `n` pairs of parentheses, including the empty string when `n` is `0`. Order the results so that, comparing them character by character, an open paren ranks before a close paren.
Summary
Building balanced brackets is an art form.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.