Bulls and Cows Time : Space : 12345678910111213141516string Solution::solve(string A, string B) { unordered_map<char, int> mp1, mp2; int b = 0, c = 0; for(int i = 0; i < A.size(); i++) { if(A[i] == B[i]) b += 1; else { mp1[A[i]] += 1; mp2[B[i]] += 1; } } for(auto [k,v] : mp2) { c += min(v,mp1[k]); } return to_string(b) + "A" + to_string(c) + "B";}