# Leetcode 20 - Valid parentheses

Note:

• This problem checks if you know about stack.
• Use a stack to record (, or {, or [ we’ve met before.
• Keep popping elements from the stack when we encounter ], }, ), if the popped element doesn’t match with the current char, return false.
• Check if stack is empty in the end.

Question:

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

An input string is valid if:

• Open brackets must be closed by the same type of brackets.
• Open brackets must be closed in the correct order.

Example:

Code: