JavaScript / TypeScript Solution
// JS\n// Runtime: 96 ms, faster than 83.23% of JavaScript online submissions for Minimum Domino Rotations For Equal Row.\n// Memory Usage: 48 MB, less than 9.3
// JS\n// Runtime: 96 ms, faster than 83.23% of JavaScript online submissions for Minimum Domino Rotations For Equal Row.\n// Memory Usage: 48 MB, less than 9.32% of JavaScript online submissions for Minimum Domino Rotations For Equal Row.\n```\nvar minDominoRotations = function (A, B) {\n  const hash = {};\n  for (let i = 1; i <= 6; i++) hash[i] = 0;\n\n  for (let i = 0; i < A.length; i++) {\n    if (A[i] !== B[i]) {\n      hash[A[i]]++;\n      hash[B[i]]++;\n    } else {\n      hash[A[i]]++;\n    }\n  }\n\n  const max = Math.max(...Object.values(hash));\n  if (max !== A.length) {\n    return -1;\n  }\n\n  let num = 0;\n  for (let i = 1; i <= 6; i++) {\n    if (hash[i] === max) {\n      num = i;\n    }\n  }\n\n  let swapsA = 0;\n  let swapsB = 0;\n  for (let i = 0; i < A.length; i++) {\n    if (A[i] !== num) {\n      swapsA++;\n    }\n    if (B[i] !== num) {\n      swapsB++;\n    }\n  }\n\n  return Math.min(swapsA, swapsB);\n};\n```\n// TS\n// Runtime: 104 ms, faster than 100.00% of TypeScript online submissions for Minimum Domino Rotations For Equal Row.\n// Memory Usage: 49.1 MB, less than 25.00% of TypeScript online submissions for Minimum Domino Rotations For Equal Row.\n```\nfunction minDominoRotations(A: number[], B: number[]): number {\n  const hash: { [key: string]: number } = {};\n  for (let i = 1; i <= 6; i++) hash[i] = 0;\n\n  for (let i = 0; i < A.length; i++) {\n    if (A[i] !== B[i]) {\n      hash[A[i]]++;\n      hash[B[i]]++;\n    } else {\n      hash[A[i]]++;\n    }\n  }\n\n  const max = Math.max(...Object.values(hash));\n  if (max !== A.length) {\n    return -1;\n  }\n\n  let num = 0;\n  for (let i = 1; i <= 6; i++) {\n    if (hash[i] === max) {\n      num = i;\n    }\n  }\n\n  let swapsA = 0;\n  let swapsB = 0;\n  for (let i = 0; i < A.length; i++) {\n    if (A[i] !== num) {\n      swapsA++;\n    }\n    if (B[i] !== num) {\n      swapsB++;\n    }\n  }\n\n  return Math.min(swapsA, swapsB);\n}\n```\nMore leetcode TypeScript solutions at https://github.com/eddyhdzg/leetcode-typescript-solutions\n
['TypeScript', 'JavaScript']