Java Solution
class Solution {\n    public int minDominoRotations(int[] tops, int[] bottoms) {\n        \n        int len = tops.length;\n        int min = Integer.MAX_VALUE;
class Solution {\n    public int minDominoRotations(int[] tops, int[] bottoms) {\n        \n        int len = tops.length;\n        int min = Integer.MAX_VALUE;\n        int [] arr = new int[2];\n        \n        arr[0] = tops[0];\n        arr[1] = bottoms[0];\n        \n        for(int i = 0; i<2; i++){\n            \n            int topRot = 0;\n            int bottomRot = 0;\n            boolean flag = true;\n            \n            for(int j = 0; j<len; j++){\n                if(tops[j]==arr[i] || bottoms[j]==arr[i]){\n                    if(tops[j]!=arr[i])  topRot++;\n                    else if(bottoms[j]!=arr[i])  bottomRot++;\n                }\n                else{\n                    flag = false;\n                    break;\n                }\n            }\n            \n            if(flag)    min = Math.min(topRot, bottomRot);\n        }\n        \n        return min==Integer.MAX_VALUE?-1:min;\n        \n    }\n}
['Java']