Easy JS Solution
\nvar minDominoRotations = function(tops, bottoms) {\n    if (tops === null || bottoms === null || tops.length === 0 ||\n        bottoms.length === 0 || tops.le
```\nvar minDominoRotations = function(tops, bottoms) {\n    if (tops === null || bottoms === null || tops.length === 0 ||\n        bottoms.length === 0 || tops.length !== bottoms.length) {\n        return -1;\n    }\n    let n = tops.length;\n    let countTop = new Array(7).fill(0), countBottom = new Array(7).fill(0);\n    let countSame = new Array(7).fill(0);\n    for (let i = 0; i < n; i++) {\n        countTop[tops[i]]++\n        countBottom[bottoms[i]]++;\n        if (tops[i] === bottoms[i]) countSame[tops[i]]++;\n    }\n    for (let i = 0; i < 7; i++) {\n        if (countTop[i] + countBottom[i] - countSame[i] === n) {\n            let swap1 = n - countTop[i];\n            let swap2 = n - countBottom[i];\n            return Math.min(swap1, swap2);\n        }\n    }\n    return -1;\n    // T.C: O(N)\n    // S.C: O(1)\n    // ex) tops:    [2,3,2,3,2] \n    //     bottoms: [5,2,6,2,2]\n    // we can see that the number that satisfies this condition, \n    // countTop[i] + countBottom[i] - countSame[i] = n, can occupy the whole row\n};\n```
['JavaScript']