Problem of the day
The first line contains an Integer 'T' which denotes the number of test cases or queries to be run. Then the test cases follow.
The first and the only line of input of each test case contains a string, as described in the task.
For each test case, the first and the only line of output prints whether the string or expression is balanced or not.
The output of every test case is printed in a separate line.
You are not required to print anything explicitly. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^5
Where N is the length of the input string or expression.
Time Limit: 1 sec
2
[()]{}{[()()]()}
[(])
Balanced
Not Balanced
In TestCase 1 there is always an opening brace before a closing brace i.e ‘{‘ before ‘}’, ‘(‘ before ‘)’, ‘[‘ before ‘]’.
In TestCase 2 there is closing brace for ‘[‘ i.e. ‘]’ before closing brace for ‘(‘ i.e. ‘)’. The balanced sequence should be ‘[()]’.
2
[[}[
[]{}()
Not Balanced
Balanced
In TestCase 1 there is no opening brace before a closing brace i.e no ‘{‘ for ‘}’.
In TestCase 2 there is exactly one closing for each opening braces and each closing brace is after their corresponding opening brace.