LeetCode 22, Medium. Topics: String, Dynamic Programming, Backtracking. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 11 parametrized pytest cases, and a playground notebook:
Problem
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Examples
Constraints
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Grind, NeetCode 150, NeetCode 250, NeetCode All. Last modified on September 7, 2026