Problem of the day
For ‘N’ = 3,
All possible combinations are:
((()))
(()())
(())()
()(())
()()()
Input consists of a single line containing a single integer ‘N’, representing the number of pairs in the parentheses.
For each test case print list of strings denoting all possible combinations for the given integer.
If there are multiple answers possible you have to print any one of them.
You are not required to print anything, it has already been taken care of. Just implement the function.
1 <= N <= 11
Time Limit: 1 sec.
2
()()
(())
There are two possible combinations of parentheses:
()()
(())
Here both the parenthesis are balanced so the possible outputs can be [ [ ()() ],[ (()) ] ].
4
()()()()
()()(())
()(())()
()(()())
()((()))
(())()()
(())(())
(()())()
(()()())
(()(()))
((()))()
((())())
((()()))
(((())))