```
public class Solution {
public String getHint(String secret, String guess) {
int cows = 0;
int bulls = 0;
int[] secret_bucket = new int[10];
int[] guess_bucket = new int[10];
for(int i = 0; i < secret.length(); i++){
if(secret.charAt(i) == guess.charAt(i)) bulls++;
else{
secret_bucket[secret.charAt(i) - '0']++;
guess_bucket[guess.charAt(i) - '0']++;
}
}
for(int i = 0; i < 10; i++){
if(secret_bucket[i] > 0 && guess_bucket[i] > 0){
cows += Math.min(secret_bucket[i],guess_bucket[i]);
}
}
return bulls + "A" + cows + "B";
}
}
```