#C13975. Balanced Brackets Checker
Balanced Brackets Checker
Balanced Brackets Checker
You are given a list of bracket sequences. A sequence is said to be balanced if all opening brackets are properly closed by the corresponding closing brackets in the correct order. The bracket pairs are defined as \( ( \) and \( ) \), \( [ \) and \( ] \), and \( \{ \) and \( \} \). An empty sequence is also considered balanced.
Your task is to read the input from stdin and for each bracket sequence, determine whether it is balanced or not. Print True
if a sequence is balanced and False
otherwise.
inputFormat
The first line of input is an integer \( n \) which represents the number of bracket sequences. Each of the following \( n \) lines contains a string representing a bracket sequence. Note that the sequence might be empty.
outputFormat
Output \( n \) lines. For each bracket sequence, output True
if the sequence is balanced, and False
otherwise.
3
()
{}
[]
True
True
True
</p>