[ Python ] ✔✔ Simple Python Solution Using Dictionary or Hashmap || O(n) 🔥✌
If It is Useful to Understand Please Upvote Me \uD83D\uDE4F\uD83D\uDE4F\n# Runtime: 1184 ms, faster than 85.42% of Python3 online submissions for Minimum Domino
# If It is Useful to Understand Please Upvote Me \uD83D\uDE4F\uD83D\uDE4F\n# Runtime: 1184 ms, faster than 85.42% of Python3 online submissions for Minimum Domino Rotations For Equal Row.\n# Memory Usage: 15.3 MB, less than 22.57% of Python3 online submissions for Minimum Domino Rotations For Equal Row.\n# Time Complexity : - O(n)\n\tclass Solution:\n\t\tdef minDominoRotations(self, tops: List[int], bottoms: List[int]) -> int:\n\n\t\t\tfrequency_tops = {1:0,2:0,3:0,4:0,5:0,6:0}\n\n\t\t\tfor i in tops:\n\t\t\t\tif i not in frequency_tops:\n\t\t\t\t\tfrequency_tops[i] = 1\n\t\t\t\telse:\n\t\t\t\t\tfrequency_tops[i] = frequency_tops[i] + 1\n\n\t\t\tfrequency_bottoms = {1:0,2:0,3:0,4:0,5:0,6:0}\n\n\t\t\tfor i in bottoms:\n\t\t\t\tif i not in frequency_bottoms:\n\t\t\t\t\tfrequency_bottoms[i] = 1\n\t\t\t\telse:\n\t\t\t\t\tfrequency_bottoms[i] = frequency_bottoms[i] + 1\n\n\t\t\tswap_number = 0\n\n\t\t\tfor i in range(1,7):\n\t\t\t\tif frequency_tops[i] + frequency_bottoms[i] >= len(tops):\n\t\t\t\t\tswap_number = i\n\n\t\t\tif swap_number == 0:\n\t\t\t\treturn -1\n\n\t\t\tmin_num1 = len(tops)-frequency_tops[swap_number]\n\t\t\tmin_num2 = len(bottoms)-frequency_bottoms[swap_number]\n\n\n\t\t\tfor i in range(len(tops)):\n\t\t\t\tif swap_number not in [tops[i],bottoms[i]]:\n\t\t\t\t\treturn -1\n\n\t\t\treturn min(min_num1,min_num2)
['Python', 'Python3']