原题链接:https://leetcode.com/problems/bulls-and-cows/
string getHint(string secret, string guess) {
int a[10] = {0}, b[10] = {0}, n = guess.size(), bulls = 0, cows = 0;
for (int i = 0; i < n; i ++ ) {
int s = secret[i] - '0';
int g = guess[i] - '0';
if (s == g) bulls ++ ;
a[s] ++;
b[g] ++;
}
for (int i = 0; i < 10 ; i ++ ) {
cows += min(a[i], b[i]);
}
cows -= bulls;
return to_string(bulls) + "A" + to_string(cows) + "B";
}