Generate Parentheses

TopicDifficultyCompanies
Backtracking
MEDIUM
Facebook
Microsoft

Given n pairs of parentheses, write a program to generate all combinations of balanced parentheses. You have to return a string array containing all possible cases.

Example

Input: n = 3
Output: A solution set is
[
"((()))",
"(()())",
"(())()",
"()(())",
"()()()"
]

Code Editor

Practice and Learn

Best way to learn is through solving real problems. Practice this problem in this code editor.