Given a string with the just the six characters - ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’. Determine if the string is balanced.
A string is balanced if all brackets exist in pairs and are closed in the correct order.
String: ({})[]
Result: Balanced
String: {()})(
Result: Not Balanced
String: {(})[]
Result: Not Balanced
The first line contains an integer ‘T’, denoting the number of test cases.
For each test case, a line containing a parentheses string.
For each test case, a line containing 1 or 0 if the string is valid or not respectively.
3
({})[]
{()})(
{(})[]
1
0
0
1 <= T <= 100
1 <= String Length <= 104