Valid Parentheses (Stack)

Problem Given a string of brackets drawn from ()[]{}, determine whether it is validly nested: every opener is closed by a matching bracket of the same type, in the correct order.

Input / Output

  • Input: string s of bracket characters.
  • Output: boolean.

Constraints

  • 1 ≤ |s| ≤ 10^4.
  • Odd length → immediately invalid.

Example

  • "([{}])" → true; "([)]" → false; "()[]" → true.
added …
LeaderboardSalaryAccount