Description
Submission
class Solution { public: bool isValid(string s) { stack<char> stk; for(auto c : s) { if(stk.empty()) { stk.push(c); continue; } if((c == ']' && stk.top() == '[') || (c == ')' && stk.top() == '(') || (c == '}' && stk.top() == '{')) { stk.pop(); continue; } stk.push(c); } if(stk.empty()) return true; return false; } };