## Solutions
### 1. stack & hash table
```python
class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
if len(s) % 2 == 1:
return False
stack = []
pairs = {"(":")", "{":"}", "[":"]"}
for c in s:
if c in "({[":
stack.append(c)
if c in ")}]":
if stack == []:
return False
elif c == pairs[stack[-1]]:
stack.pop()
else: return False
if stack == []:
return True
else:
return False
```
- Complexity Analysis
- Time complexity is On, for loop
- Space complexity is On
- Paris dict is O1/constant, in worst case the length is 3
- stack is On, in worst case we will store n element without any pop
#### learned
- [[Stack]] FILO
- use [[Hash Table]] to store the pairs
- grammar
- `if c == "(" or c == "{" or c == "[":` → `if c in "({[":`