```
class Solution(object):
def isValid(self, s):
stack=[]
for x in s:
if x=="(" or x=="{" or x=="[":
stack.insert(0,x)
else:
if len(stack)==0:
return False
if abs(ord(x)-ord(stack.pop(0)))>2:
return False
return len(stack)==0
```