class Solution {
public boolean isValid(String s) {
Stack<Character> stack = new Stack<>();
char[] chars=s.toCharArray();
for(char c: chars){
if(c == '(') stack.push(')');
else if (c=='{') stack.push('}');
else if(c=='[')stack.push(']');
else{
if(stack.size()==0||stack.peek()!=c)return false;
stack.pop();
}
}
return stack.size()==0;
}
}
11-15
11-15