String practice 2
Submit solution
C, C++, Python3
Points:
1
Time limit:
1.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
Brackets are used in many places, and in this task your job is to make sure the square brackets are syntactically correct. The rules are very simple, matching pairs of brackets are considered valid.
E.g. the following brackets are valid:
[] [ [ ] ]
[ []]
The following is invalid:
[] ]
Input Specification
Each line will contain a single test case. Each case will contain no more than 200 characters.
There will be multiple test cases, until EOF in the end.
Output Specification
The output should contain the same number of lines as input, each line either
Yes
or No
, indicating whether the sequence is valid.
Sample Input
[] [ [ ] ]
[ []]
[] ]
][
Sample Output
Yes
Yes
No
No
Comments
Hint:
In Python, to keep reading from
stdin
untilEOF
, you can do this:Hint:
In C++, to keep reading in a complete line until EOF, you can do this: