153. Generate Parentheses

Given an integer n.Generate all possible combinations of well-formed parentheses of length 2 x N.

Example 1:

Input : n = 3

Output : [ "((()))" , "(()())" , "(())()" , "()(())" , "()()()" ]

Example 2:

Input : 2

Output : [ "(())" , "()()" ]

Now Your Turn!

Pick the correct output for the given input

Input : 1

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 8

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
vector<string> generateParenthesis(int n) {
//your code goes here
}
};
Test Case

Input:

N