C++
```\nint minDominoRotations(vector& A, vector& B) {\n        vector countA(7), countB(7), same(7);\n        int n = A.size();\n        for (int i = 0; i < n; ++
```\nint minDominoRotations(vector<int>& A, vector<int>& B) {\n        vector<int> countA(7), countB(7), same(7);\n        int n = A.size();\n        for (int i = 0; i < n; ++i) {\n            countA[A[i]]++;\n            countB[B[i]]++;\n            if (A[i] == B[i])\n                same[A[i]]++;\n        }\n        for (int i  = 1; i < 7; ++i)\n            if (countA[i] + countB[i] - same[i] == n)\n                return n - max(countA[i], countB[i]);\n        return -1;\n    }
[]