#231. 括号嵌套判断

    ID: 231 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归字符串

括号嵌套判断

Parenthesis Nesting Check

Background

Congcong is learning string processing, and Dawei has given him a problem about parenthesis nesting.

Problem Description

Given a string, return true if it is a nesting of zero or more pairs of parenthesis, like (()) or ((())). Suggestion: check the first and last characters, and then recur on what's inside them.

Input Format

Input is given from standard input in the following format.

A string SS.

Output Format

Output is printed to standard output in the following format.

Output true if the string meets the requirements; otherwise, output false.

Sample

(
true
((
true
(((
false

Sample Explanation

None

Constraints

Time limit: 1 second, Memory limit: 1024 KiB for each test case.