String And Its Frequency Time : Space : 1234567891011121314string Solution::solve(string A) { unordered_map<char,int> freq; for(auto a : A) freq[a]++; string res = ""; for(auto a : A) { if(freq.count(a)) { res.push_back(a); res += to_string(freq[a]); freq.erase(a); } } return res;}