package com.fishercoder.solutions;

public class _299 {
    public static class Solution1 {
        public String getHint(String secret, String guess) {
            int[] secretCows = new int[10];
            int[] guessCows = new int[10];
            int bulls = 0;
            for (int i = 0; i < secret.length(); i++) {
                if (guess.charAt(i) == secret.charAt(i)) {
                    bulls++;
                } else {
                    secretCows[Character.getNumericValue(secret.charAt(i))]++;
                    guessCows[Character.getNumericValue(guess.charAt(i))]++;
                }
            }
            int cows = 0;
            for (int i = 0; i < 10; i++) {
                cows += Math.min(secretCows[i], guessCows[i]);
            }
            return bulls + "A" + cows + "B";
        }
    }
}

@@ -29,16 +29,65 @@
 tions;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 public c
@@ -872,11 +872,1397 @@
  %7D%0A    %7D
+%0A%0A    public static class Solution2 %7B%0A        /**%0A         * My completely original solution on 12/24/2021.%0A         */%0A        public String getHint(String secret, String guess) %7B%0A            int bulls = 0;%0A            int cows = 0;%0A            boolean%5B%5D bulled = new boolean%5Bsecret.length()%5D;%0A            Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A            for (int i = 0; i %3C secret.length(); i++) %7B%0A                if (secret.charAt(i) == guess.charAt(i)) %7B%0A                    bulled%5Bi%5D = true;%0A                    bulls++;%0A                %7D%0A            %7D%0A            for (int i = 0; i %3C secret.length(); i++) %7B%0A                if (!bulled%5Bi%5D) %7B%0A                    int num = Character.getNumericValue(secret.charAt(i));%0A                    map.put(num, map.getOrDefault(num, 0) + 1);%0A                %7D%0A            %7D%0A            for (int i = 0; i %3C secret.length(); i++) %7B%0A                if (!bulled%5Bi%5D) %7B%0A                    int num = Character.getNumericValue(guess.charAt(i));%0A                    if (map.getOrDefault(num, 0) %3E 1) %7B%0A                        map.put(num, map.get(num) - 1);%0A                        cows++;%0A                    %7D else if (map.getOrDefault(num, 0) == 1) %7B%0A                        map.remove(num);%0A                        cows++;%0A                    %7D%0A                %7D%0A            %7D%0A            return bulls + %22A%22 + cows + %22B%22;%0A        %7D%0A    %7D
 %0A%7D%0A

add a solution for 299