Simple in Python
Intuition\nThe intuition is that we need to figure out the most common number in both arrays, as that will be the number at either top or bottom after the swaps
# Intuition\nThe intuition is that we need to figure out the most common number in both arrays, as that will be the number at either top or bottom after the swaps. \n\nWe also need to make sure that the most common number is in either tops[i] or bottoms[i], because if it is not, then we know we can return -1.\n\nFinally, for the result we can see whether the top or bottom has the higher frequency of the most common number and subtract it from the total length to find the minimum swaps.\n\n# Approach\n1. Find the most common number in both tops and bottoms.\n2. Iterate through length of array, to see if most common number is in either tops[i] or bottoms[i]. If not, then return -1\n3. Return the difference between length and max frequency of most common number at either the top or bottom.\n\n# Code\n```\nclass Solution:\n    def minDominoRotations(self, tops: List[int], bottoms: List[int]) -> int:\n        \n        nlen = len(tops)\n        topC = Counter(tops)\n        bottomC = Counter(bottoms)\n        totalC = topC + bottomC\n\n        num, freq = totalC.most_common()[0]\n\n        for i in range(nlen):\n            if num != tops[i] and num != bottoms[i]:\n                return -1\n\n        return nlen-max(topC[num], bottomC[num])\n```
['Python3']