Three Kinds of Brackets
The string uses three bracket kinds: (), [], {}. Is it properly balanced and properly nested?
Input: one line with a bracket string.
Output: YES or NO.
Constraints:
- 1 ≤ |S| ≤ 105
Sample Tests
Input 1
{[()]}
Output 1
YES
Input 2
([)]
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.