<awangdev>299. Bulls and Cows_2.java
public String getHint(String secret, String guess) {
        if (secret == null || guess == null || secret.length() == 0 || guess.length() == 0) {
            return "0A0B";
        }
        
        char[] secretArr = secret.toCharArray();
        char[] guessArr = guess.toCharArray();
        
        Map<Character, Integer> secretMap = new HashMap<>();
        Map<Character, Integer> guessMap = new HashMap<>();
        
        int bulls = 0;
        for (int i = 0; i < secretArr.length; i++) {
            char a = secretArr[i], b = guessArr[i];
            if (a == b) {
                bulls++;
            } else {
                secretMap.putIfAbsent(a, 0);
                secretMap.put(a, secretMap.get(a) + 1);
                guessMap.putIfAbsent(b, 0);
                guessMap.put(b, guessMap.get(b) + 1);
            }
        }
        
        int cows = 0;
        for (Map.Entry<Character, Integer> entry : secretMap.entrySet()) {
            char key = entry.getKey();
            if (guessMap.containsKey(key)) {
                cows += Math.min(entry.getValue(), guessMap.get(key));
            }
        }

        return String.format("%sA%sB", bulls, cows);
    }
public String var_0 ( String var_2 , String var_3 ) {
  if ( var_2 == null || var_3 == null || var_2 . length ( ) == 0 || var_3 . length ( ) == 0 ) {
    return "0A0B" ;
  }
  char [ ] var_9 = var_2 . toCharArray ( ) ;
  char [ ] var_10 = var_3 . toCharArray ( ) ;
  Map < Character , Integer > var_15 = new HashMap < > ( ) ;
  Map < Character , Integer > var_16 = new HashMap < > ( ) ;
  int var_17 = 0 ;
  for ( int var_18 = 0 ;
  var_18 < var_9 . length ;
  var_18 ++ ) {
    char var_19 = var_9 [ var_18 ] , var_20 = var_10 [ var_18 ] ;
    if ( var_19 == var_20 ) {
      var_17 ++ ;
    }
    else {
      var_15 . putIfAbsent ( var_19 , 0 ) ;
      var_15 . put ( var_19 , var_15 . get ( var_19 ) + 1 ) ;
      var_16 . putIfAbsent ( var_20 , 0 ) ;
      var_16 . put ( var_20 , var_16 . get ( var_20 ) + 1 ) ;
    }
  }
  int var_25 = 0 ;
  for ( Map . Entry < Character , Integer > var_27 : var_15 . entrySet ( ) ) {
    char var_29 = var_27 . getKey ( ) ;
    if ( var_16 . containsKey ( var_29 ) ) {
      var_25 += Math . min ( var_27 . getValue ( ) , var_16 . get ( var_29 ) ) ;
    }
  }
  return String . format ( "%sA%sB" , var_17 , var_25 ) ;
}
