class Solution { public: bool isValid(string s) { if (s.size() == 0) { return true; } std::unordered_map hash = { {'(', ')'}, {'[', ']'}, {'{', '}'}, }; std::unordered_map::iterator iter; std::stack test; for (string::size_type i=0;isecond) { test.pop(); } else if (hash.find(s[i]) != hash.end()) { test.push(s[i]); } else { return false; } } else { if (hash.find(s[i]) != hash.end()) { test.push(s[i]); } else { return false; } } } return test.empty(); } };