#K42002. Valid Parentheses Checker
Valid Parentheses Checker
Valid Parentheses Checker
Given a string consisting solely of the characters '(', ')', '{', '}', '[' and ']', determine whether the string forms a valid sequence of parentheses. A string is considered valid if every opening bracket has a corresponding closing bracket in the correct order.
Formally, the rules are:
1. Every opening bracket must be closed by the same type of bracket.
2. Opening brackets must be closed in the correct order.
Your task is to implement a program that reads a single string from standard input and prints "YES" if the string is valid, otherwise prints "NO".
inputFormat
The input consists of a single line containing a string S, which contains only the characters '(', ')', '{', '}', '[' and ']'. The string may be empty.
outputFormat
Output a single line: "YES" if the input string is a valid sequence of parentheses according to the rules, otherwise "NO".## sample
()
YES