Search across blog, articles, projects, courses, and community posts
A string of brackets is valid if every opening bracket is closed by the same kind of bracket, in the correct order. Read a string made of (), [] and {} and print YES if it is valid, otherwise NO.
Input: one line of bracket characters.
Output: YES or NO.
The string has 1 to 1000 characters, all from ()[]{}.
()[]{}YES
(]
NO