Problems
10066 - Parentheses Matching
SUBMIT PROBLEM

Parentheses Matching

Time Limit: 0.5 sec

 

The Problem

This is a simple problem for you. In this problem you are given a string consisting of parentheses ( ). If all parentheses are correct in their position then the sequence of string is said to be correct.

 

Example:

((())()) is correct. But ((())))(() is not correct.

 

Now you have to write a simple code to check the correctness of the given string. 

  

The Input

There are several lines in the input file. Each line of the input contains a string S. The length of the string is not greater than 50. Input is terminated by EOF.

 

The Output

The output for each input line is "YES" if the input string is correct parentheses balance otherwise "NO".

 

Sample Input

(()(())(

(()()))()(

()()()(())(()())()()

 

Sample Output

NO

NO

YES

 

 

 

 

Online Practice Contest 4 [School & College Level]

Problem Setter: Milton Deb