Parentheses P31111


Statement
 

pdf   zip

thehtml

Given a sequence made up of only ‘(’ and ‘)’, tell if the parentheses close correctly.

Input

Input consists of a sequence of parentheses.

Output

Print “yes” or “no”, depending on whether the parentheses close correctly or not.

Public test cases
  • Input

    (())()()
    

    Output

    yes
    
  • Input

    (()()))(
    

    Output

    no
    
  • Input

    ())()
    

    Output

    no
    
  • Input

    ((()
    

    Output

    no
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python Rust