Generate all parenthesis

Given n pairs of parentheses, write a function to generate 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 : n

Output format : Print all possible valid parenthesis in different lines

Sample Input :
3

Sample Output :

((()))
(()())
(())()
()(())
()()()

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem