Valid Parentheses

Stacks · easy

Implement `isValid(s)` that returns `true` if every opening bracket `(`, `[`, `{` in string `s` is closed by the correct closing bracket in the correct order. Example: `isValid("()[]{}")` → `true`, `isValid("(]")` → `false`.

Hints
  • Use an array as a stack.
  • Push opening brackets; for closing brackets, pop and verify it matches.
Loading...

Run your code to see results.