- You have been given a string s which consists of only characters '[', ']', '(', ')', '{', and '}'. Your task is to check whether the string is valid or not.
- Open brackets has to be closed with closing brackets properly.
- Open and closed brackets has to be in proper order.
You will be given a string 's'.
Constraints
1 <= s.length <= 104
s consists of parentheses only i.e. '()[]{}'.
The task is to complete the function isValid() which takes a string as a parameter. You will have to return true after checking if the string is valid otherwise false.
Sample Input 1
"()[]{}"
Sample Output 1
true
Sample Input 2
"([)]"
Sample Output 2
false
Explanation
All the brackets exists in a pair with proper ordering.
s = "(((}", s = "(]", and s="({[]}]" are invalid.