Generate all parenthesis

Given n pairs of parentheses, write a function to generate and print all combinations of well-formed parentheses. That is, you need to generate all possible valid set of parenthesis that can be formed with given number of pairs.

Input format :
Integer n
Output format :
Print all possible valid parenthesis in different lines
Constraints :

1 <= n <= 10

Sample Input :
3
Sample Output :
((()))
(()())
(())()
()(())
()()()

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem