← Practice · Stack

Valid Parentheses Easy

Given a string s made only of the characters ( ) [ ] { }, return true if every opening bracket is closed by the same type of bracket and in the correct order.

Examples

  • "()[]{}" -> true
  • "([)]" -> false

Define a function named isValid in JavaScript.

00:00▶ Visualize

JavaScript · Tab indents · Ctrl/⌘+Enter runs the tests