Make The String Great LeetCode solution in C++
1class Solution {2public:3string makeGood(string s) {4stack<char> st;5st.push(s[0]);6string ans = "";78for (int i = 1; i < s.size(); ++i) {9if (!st.empty() and (st.top() == s[i] + 32 or st.top() == s[i] - 32)) {10cout << "top :" << st.top() << endl;11st.pop();12}1314else {15st.push(s[i]);16}17}1819while (!st.empty()) {20// cout<<st.top()<<"";21ans += st.top();22st.pop();23}24reverse(ans.begin(), ans.end());2526return ans;27}28};