31. Valid Parentheses

s contains only the characters ()[]{}. It is valid when every opening bracket is closed by the same type of bracket, in the correct order.

Example 1

Input: s = "()[]{}"
Output: true

Example 2

Input: s = "(]"
Output: false
Hint 1

The most recent unclosed bracket must be closed first: last in, first out.

StackString