Submit | All submissions | Best solutions | Back to list |
EIUBRACKET2 - BALANCED PARENTHESES |
You are given a string containing just the characters '(', ')', '{', '}', '[' and ']'. Your task is to determine if the input string is valid. An input string is valid if:
- Open brackets must be closed by the same type of brackets.
- Open brackets must be closed in the correct order.
Input
An interger N (N ≤ 10) is the number of testcases
Each of the next N lines contains a string of only brackets S (0 ≤ |S| ≤ 104).
Output
true if S is valid, otherwise false.
Sample
Input |
Output |
1 {[]} |
true |
2 ([)] {[]} |
false true |
Added by: | Ha Minh Ngoc |
Date: | 2024-01-30 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |