#K67872. Balanced Parentheses
Balanced Parentheses
Balanced Parentheses
This problem requires you to decide whether a given sequence of parentheses is balanced. A sequence is considered balanced if every opening parenthesis has a corresponding closing parenthesis in the correct order. More formally, if we denote an opening parenthesis as \(\{,\(,\[\) and its corresponding closing parenthesis as \(\},\),\]\), then the sequence \(S\) is balanced if each opening bracket is closed by the correct type of bracket and the brackets are closed in the correct order.
For example:
- The sequence "()[]{}" is balanced.
- The sequence "([{}])" is balanced.
- The sequence "({[}])" is not balanced.
inputFormat
The input consists of a single line containing a string (S) which represents the sequence of parentheses. The string may include the characters '(', ')', '{', '}', '[' and ']'.
outputFormat
Output a single line: "YES" if the sequence is balanced, otherwise "NO".## sample
()[]{}
YES