Java easy and intuitive solution
Using 3 arrays\nwe have 1, 2, 3, 4, 5, 6  index\ncountSum is total number of occurrences with each index in either A or B\ncountA is total number of occurrences
Using 3 arrays\nwe have 1, 2, 3, 4, 5, 6  index\ncountSum is total number of occurrences with each index in either A or B\ncountA is total number of occurrences with each index only in A but not in B\ncountB is total number of occurrences with each index only in B but not in A\nOnly if countSum[i] = A.length will the problem have a solution\n\nreturn `Math.min(countA, countB)`  since no need for swap when A[i] = B[i] \n```\nclass Solution {\n    public int minDominoRotations(int[] A, int[] B) {\n        int len  = A.length;\n        int[] countSum = new int[7], countA = new int[7], countB = new int[7];\n\t\t\n        for(int i = 0 ; i < len; i++) {\n            if(A[i] == B[i]) \n                countSum[A[i]]++;\n            else {\n                countSum[A[i]]++;\n                countSum[B[i]]++;\n                countA[A[i]]++;\n                countB[B[i]]++;\n            }\n        }\n        \n        for(int i = 1; i <= 6; i++) {\n            if(countSum[i] == len) \n                return Math.min(countA[i], countB[i]);\n        }\n        \n        return -1;\n    }\n}\n```
['Java']