Loading practice problems…
Loading your practice workspace…
Loading code editor…
24 / 29
Sign in
Algorithms/Stack

Valid Parentheses

easy20 min

Given a string containing only parentheses, brackets, and braces, return true when every opening symbol is closed by the same type in the correct order.

An empty stack at the end means every opening symbol was matched.

Example 1

Inputs = "()[]{}"

Outputtrue

Example 2

Inputs = "([)]"

Outputfalse

Constraints

  • 1 ≤ s.length ≤ 10,000
  • s contains only ()[]{}.
StackStrings