Valid Parentheses

For this question we ask you to determine whether or not a string has valid parentheses. A string has valid parentheses if each bracket is closed and opened in the same order and has the same type. Parentheses has 3 types (), {} and []

Input

  • s: String containing the parentheses

Output

Whether or not the string is valid

Examples

Example 1:

Input:

1s = ()

Output: true

Explanation:

This is a valid parentheses sequence.

Example 2:

Input:

1s = (}

Output: false

Explanation:

This is not valid as } cannot match (.

Constraints

  • 1 <= s.length <= 100000

Try it yourself

Solution

โ†
โ†‘TA ๐Ÿ‘จโ€๐Ÿซ