CT27980

The Bracket Audit Beneath Will-o-Wisp

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Caravans arrive at the fen lights of Will-o-Wisp with crates of inscriptions, and Tanya the valuer must account for every last one. Task: A string contains only '(' and ')'. Print YES if it is a balanced bracket sequence, otherwise NO. Input format: One line with a string of parentheses. Output format: Print YES or NO. Constraints: 1 <= |s| <= 904; characters are '(' and ')'.

Example 1:

Input: ())))))((()))(())()))))()((())()())))(((()))()(((()))(((()()((())()(()())(()(()
Output: NO

Example 2:

Input: )))()())))))(((()))(())()(((()())()(()())()((())))()(()()))))())())(()())((()(()))(())()(()()))((())())(()(()(((()(())()))))())(()())((())))())()()))))))))()()((()(((()))(((()()(()))(())))(
Output: NO

Example 3:

Input: (((((((((((((((((())))))))))))))))))
Output: YES

Constraints:

1 <= |s| <= 904; characters are '(' and ')'.

Loading...
Test Cases:No test cases
No test cases available.