class Solution { public: bool isValid(string s) { stack st; unordered_map mapping = {{')','('}, {'}','{'}, {']','['}}; for(char c: s){ if(mapping.find(c) == mapping.end()) st.push(c); else if(!st.empty() && mapping[c] == st.top()) st.pop(); else return false; } return st.empty(); } };