Problems > Three Kinds of Brackets

Three Kinds of Brackets

Difficulty: 1200 2000 ms 128 MB

strings stack

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

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.