```
map<int, int> a;
int countA = 0, countB = 0;
for (int i = 0; i<secret.size(); i++)
{
if ( secret[i] == guess[i] ) countA++;
a[secret[i]]++;
}
for (int i = 0; i<secret.size(); i++)
{
if (a[guess[i]]-- > 0) countB++;
}
return to_string(countA) + 'A' + to_string(max(countB-countA,0)) + 'B';
```