Minimum Domino Rotations For Equal Row LeetCode solution in Python
1class Solution:2def minDominoRotations(self, tops: List[int], bottoms: List[int]) -> int:3sames = [tops[i] for i in range(len(tops)) if tops[i] == bottoms[i]]45same_count = collections.Counter(sames)6bottom_count = collections.Counter(bottoms)7top_count = collections.Counter(tops)89for n in range(1, 7):10if bottom_count[n] + top_count[n] - same_count[n] == len(tops):11return min(bottom_count[n], top_count[n]) - same_count[n]1213return -1