#C1284. Balanced Brackets Checker
Balanced Brackets Checker
Balanced Brackets Checker
Given a string s consisting solely of the characters '(', ')', '[', ']', '{', and '}', determine if the string is balanced. A string is considered balanced if and only if:
1. Every opening bracket has a corresponding closing bracket of the same type.
2. The brackets are closed in the correct order.
This condition can be formally expressed as: $$\forall prefix\ of\ s,\ #opening\geq #closing \quad \text{and overall }\ #opening = #closing.$$
Note that if the string contains any characters other than the specified brackets, it should be considered unbalanced.
inputFormat
The input is provided via standard input (stdin) as a single line. This line contains the string s to be checked. The string may be empty.
outputFormat
Print to standard output (stdout) either 'True' if the string is balanced, or 'False' otherwise.## sample
({[]})
True