The definition of correctly paired parentheses means that if it is opened with a '(' character, it must be closed with a ')' character.
For instance,

  • "()()" or "(())()" is a correct parenthesis.
  • ")()(" or "(()(" is an incorrect parenthesis.

Given a string s consisting only of '(' or ')', complete a solution function that returns true if the string s is the correct parenthesis and false if it is not.

  • Length of string s: natural number less than 100,000
  • The string s consists of only '(' or ')'.

s answer
"()()" true
"(())()" true
")()(" false
"(()(" false

Example #1

Same as above example.

Result Stop
Result of [Run] or [Submit] will be displayed here