https://leetcode.com/problems/valid-parentheses/
class Solution {
public:
bool isValid(string s) {
stack<char> st;
if(s.size()==0) return true;
for(int i=0;i<s.size(); i++){
if(s[i]=='{' || s[i]=='[' || s[i]=='(') st.push(s[i]);
else if(s[i]=='}'){
if(!st.empty()&&st.top()=='{') st.pop();
else return false;
}
else if(s[i]==']'){
if(!st.empty()&&st.top()=='[') st.pop();
else return false;
}
else if(s[i]==')'){
if(!st.empty()&&st.top()=='(') st.pop();
else return false;
}
}
if(!st.empty()) return false;
else return true;
}
};