12. Valid Parentheses
EasyStackString
A string contains only the characters ()[]{}. Print YES if every bracket is closed by the same type in the correct order, otherwise NO.
Input format
A single string.
Output format
YES or NO.
Example 1
Input
()[]{}Output
YES
Example 2
Input
(]
Output
NO
Constraints
1 ≤ length ≤ 10⁴
Read input from standard input and print the answer to standard output. Your code is judged against 7 test cases, most of them hidden.
Loading the MyLoginn IDE…