12. Brackets

Difficulty: 

We have a string of brackets, and we would like to make sure each bracket is properly opened and closed. The string has any number of (, ), [, ], {, and }. A valid string follows the common-sense rules of opening and closing brackets, so in other words, the formal rules are:

For example, {[()[]]()}() is valid, but [(]) is not. Given a string, your function should determine if it is valid.

Input:

isValid("{[()[]]()}()");

Output:

true

Time Limit:

500 (ms)

Hint (hover to see):

  • Hint #1



Results

ProblemsAcceptedWrongTimed OutError
160000

Input:

Expected Output:

Output: