---
# System prepended metadata

title: Hashmap
tags: [Week_2, Hashmap]

---

###### tags: `Week_2`, `Hashmap`

# Hashmap

## 299. [ Bulls and Cows](https://leetcode.com/problems/bulls-and-cows/)
Beny
(bad quetion)
```csharp=
public class Solution {
    public string GetHint(string secret, string guess) {
        int bulls = 0, cows = 0;
        int[] sm = new int[10];
        for(int i = 0; i < secret.Length; i++){
            if(secret[i] == guess[i]){
                bulls ++;
            }else{
                if(sm[secret[i] - '0']++ < 0){
                    cows ++;
                }
                if(sm[guess[i] - '0']-- > 0){
                    cows ++;
                }
            }            
        }
        return bulls + "A" + cows + "B";
    }
}
```