Balanced Brackets Time : O(n) Space : O(n) 12345678910111213141516171819202122using namespace std;bool balancedBrackets(string str) { vector<char> st; unordered_map<char, char> mp{ {')','('}, {']','['}, {'}','{'} }; for(auto& ch : str) { if(mp.count(ch)) { if(!st.empty() and mp[ch] == st.back()) { st.pop_back(); } else return false; } else if(ch == '(' or ch == '{' or ch == '['){ st.push_back(ch); } } return st.empty();}