@@ -0,0 +1,1577 @@
+class Solution %7B%0A    public int minDominoRotations(int%5B%5D A, int%5B%5D B) %7B%0A        int resultWithoutSwapFirst = findRotation(A, B);%0A        %0A        int temp = A%5B0%5D;%0A        A%5B0%5D = B%5B0%5D;%0A        B%5B0%5D = temp;%0A        %0A        int resultWithSwapFirst = findRotation(A, B);%0A        %0A        if (resultWithoutSwapFirst == -1) %7B%0A            return resultWithSwapFirst;%0A        %7D else if (resultWithSwapFirst == -1) %7B%0A            return resultWithoutSwapFirst;%0A        %7D else %7B%0A            return Math.min(resultWithoutSwapFirst, resultWithSwapFirst + 1);%0A        %7D%0A    %7D%0A    %0A    private int findRotation(int%5B%5D A, int%5B%5D B) %7B%0A        int result = A.length + 1;%0A        %0A        int moveUp = 0;%0A        for (int i = 1; i %3C A.length; i++) %7B%0A            if (A%5Bi%5D != A%5B0%5D) %7B%0A                if (B%5Bi%5D == A%5B0%5D) %7B%0A                    moveUp ++;%0A                %7D else %7B%0A                    moveUp = -1;%0A                    break;%0A                %7D%0A            %7D%0A        %7D%0A        %0A        if (moveUp != -1) %7B%0A            result = Math.min(moveUp, result);%0A        %7D%0A        %0A        int moveDown = 0;%0A        for (int i = 1; i %3C B.length; i++) %7B%0A            if (B%5Bi%5D != B%5B0%5D) %7B%0A                if (A%5Bi%5D == B%5B0%5D) %7B%0A                    moveDown ++;%0A                %7D else %7B%0A                    moveDown = -1;%0A                    break;%0A                %7D%0A            %7D%0A        %7D%0A        %0A        if (moveDown != -1) %7B%0A            result = Math.min(result, moveDown);%0A        %7D%0A        %0A        if (result == A.length + 1) %7B%0A            return -1;%0A        %7D%0A        %0A        return result;%0A    %7D%0A%7D%0A

Create MinimumDominoRotationsForEqualRow.java