Valid Parentheses

Easy
Stacks Stack String

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

Constraints

1 ≤ s.length ≤ 10^4

Examples

Example 1:
Input: ()
Output: true
Example 2:
Input: ()[]{}
Output: true
Example 3:
Input: (]
Output: false

Hints

Use a stack. Push opening brackets, pop on closing.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.