package leetcode;

/**
 * https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/
 */
public class Problem1007 {
    public int minDominoRotations(int[] A, int[] B) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1007 prob = new Problem1007();
        System.out.println(prob.minDominoRotations(new int[]{2, 1, 2, 4, 2, 2}, new int[]{5, 2, 6, 2, 3, 2})); // 2
        System.out.println(prob.minDominoRotations(new int[]{3, 5, 1, 2, 3}, new int[]{3, 6, 3, 3, 4})); // -1
    }
}

@@ -186,358 +186,933 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1007 prob = new Problem1007();%0A        System.out.println(prob.minDominoRotations(new int%5B%5D%7B2, 1, 2, 4, 2, 2%7D, new int%5B%5D%7B5, 2, 6, 2, 3, 2%7D)); // 2%0A        System.out.println(prob.minDominoRotations(new int%5B%5D%7B3, 5, 1, 2, 3%7D, new int%5B%5D%7B3, 6, 3, 3, 4%7D)); // -1
+int%5B%5D aCounts = new int%5B6%5D;%0A        int%5B%5D bCOunts = new int%5B6%5D;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            aCounts%5BA%5Bi%5D - 1%5D++;%0A            bCOunts%5BB%5Bi%5D - 1%5D++;%0A        %7D%0A        int max = 0;%0A        boolean a = true;%0A        int val = 0;%0A        for (int i = 0; i %3C aCounts.length; i++) %7B%0A            if (aCounts%5Bi%5D %3E max) %7B%0A                max = aCounts%5Bi%5D;%0A                val = i + 1;%0A                a = true;%0A            %7D%0A            if (bCOunts%5Bi%5D %3E max) %7B%0A                max = bCOunts%5Bi%5D;%0A                val = i + 1;%0A                a = false;%0A            %7D%0A        %7D%0A        int answer = 0;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            if (A%5Bi%5D == val && a %7C%7C B%5Bi%5D == val && !a) %7B%0A                continue;%0A            %7D%0A            if (A%5Bi%5D == val %7C%7C B%5Bi%5D == val) %7B%0A                answer++;%0A            %7D else %7B%0A                return -1;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1007