#C13120. Balanced Brackets Checker
Balanced Brackets Checker
Balanced Brackets Checker
Given a string s consisting only of the characters (' , )
, { , }
and [ , ]
, determine whether the brackets in the string are balanced.
A sequence of brackets is considered balanced if every opening bracket has a corresponding closing bracket in the correct order. For example, the string ()[]{}
is balanced, while (]
and ([)]
are not.
Please implement a solution that reads the input from stdin and writes the output to stdout. The output should be True
if the string is balanced and False
otherwise.
The matching follows the standard bracket pairs: \( ( \) \), \{ \} and \[ \].
inputFormat
The input consists of a single line containing a string s composed solely of the characters '(', ')', '{', '}', '[' and ']'.
outputFormat
Output a single line to stdout: print True
if the string has balanced brackets and False
otherwise.
()
True