Problem of the day
Conditions for valid parentheses:
1. All open brackets must be closed by the closing brackets.
2. Open brackets must be closed in the correct order.
()()()() is a valid parentheses.
)()()( is not a valid parentheses.
The first line of input contains an integer βTβ, which denotes the number of test cases. Then each test case follows.
Each line of the test case contains an integer βNβ denoting the pair of parentheses.
For each test case print, all the combinations of balanced parentheses separated by a single space.
The output of each test case will be printed on a separate line.
1. You don't need to print anything, it has already been taken care of. Just implement the given function.
2. You can return strings in any order.
1 <= T <= 5
1 <= N <= 10
Time Limit : 1 sec.
2
2
3
(())
()()
((()))
(()())
(())()
()(())
()()()
Test Case 1:
For 2 pair of parentheses the combinations of balanced parentheses will be (()) ()()
Test Case 2:
For 3 pair of parentheses the combinations of balanced parentheses will be
((())) (()()) (())() ()(()) ()()()
2
1
4
()
(((())))
((()()))
((())())
((()))()
(()(()))
(()()())
(()())()
(())(())
(())()()
()((()))
()(()())
()(())()
()()(())
()()()()